From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D7CCC636CC for ; Mon, 20 Feb 2023 14:43:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C07E16B0073; Mon, 20 Feb 2023 09:43:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB7FA6B0074; Mon, 20 Feb 2023 09:43:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7F1A6B0075; Mon, 20 Feb 2023 09:43:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 986236B0073 for ; Mon, 20 Feb 2023 09:43:14 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 77983A3194 for ; Mon, 20 Feb 2023 14:43:14 +0000 (UTC) X-FDA: 80487937908.22.B9BDA7C Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf19.hostedemail.com (Postfix) with ESMTP id 9E36B1A000A for ; Mon, 20 Feb 2023 14:43:12 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=G0GxW3hB; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676904192; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=U4YOIGiGMmw0c6qR11YlP294P6f5lghZmItPOtjXeCQ=; b=2t3aVsdCWW2D7JA4EpLc1yxUF0/u0w3pXoJTfZ47u2uylcbOP8RBlBt7JOR8HbKZmSetjJ qHXcz7+CT6j837o2GZxUGX07c3MOe6WLGHghkMiA4mDZKSnAoqxMqacJ5m5MKudMzsJ1jD otuBsyOq9VGzIz/es0JqplGj3gRGaMQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=G0GxW3hB; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676904192; a=rsa-sha256; cv=none; b=Z94KplM4QhQrDiTqzO05z/riaLBf1uYIWf7eAFBopKFPULjiQeMgthCHu5RYNaxDZKZnDY R3pYJp+jK6zc8sChcGlCQ2rIlc+qicgQc6XiGMosql34UN9EY2JdCimW3ddvbgoTfqE2xJ izJqbOnzFEjOs/MV7T8VOG+1pONDB40= Received: by mail-pl1-f169.google.com with SMTP id t14so1926579plo.2 for ; Mon, 20 Feb 2023 06:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=U4YOIGiGMmw0c6qR11YlP294P6f5lghZmItPOtjXeCQ=; b=G0GxW3hBv3oXa4hWac/J+65ckLC27dxidlkonbDoMETJwasss5GKdI7TO63Z3UygtI vhOhSGz6c7wf1W0tg6/OUsFVF6nF9cY/oQjsinVh/usK4Ysc2OyMtIBfWHbhOQLtiPe2 KV/CYTlQWrGtrpjRir7QrrdEg6InjSoVyUsHBs+kBcvM3XLB95tSWjBaQ+tMgJ9qIQ/5 TJdIYjTdDT6pTf45cSeB4gkh9q7YJS0jMycLiEnx4sg/dkeZM5zGXbTTP1uOzk8AwfUM vKSk9UFFAyidrG6YaqnItISsD50pdM5ODDHh1PNqE8d9OFauem0Nv1EqeBno+Rj5iJ7D Qhcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=U4YOIGiGMmw0c6qR11YlP294P6f5lghZmItPOtjXeCQ=; b=vuw0A8MQtG2qjkD+M4JxqhOZNARz5XKaZDsc3WHlvcIS/LDOJSbBqiN6NsEJqWaO4n 1VSevWr9SwqmH221MfahuQEof6p9pkK8W4trvJBJEWEPyoRE+3tS6DX+qaCnGq8vJpF+ Rw59xUTEDK4sgWZbF5OrxztnQ1vToS+WL6fTouQr1yDd2S6h/b9kbphpAzmND3v76aF4 p5zRCabaEOr1OV3KsND1ncElbHBZJ4HNZ2IVd2oiUDI/ke9dCTTGuLFaei/1qT91vEDd s40l0WRExY5W4L8KPQP76gJhbGIqs+T7LYxPMt/NSKLQJempxcFBvCMiXWarlkfdfddo dxcg== X-Gm-Message-State: AO0yUKUQsqrlBv0gWJ5Kp9MMNBxVyCZJnTA8MbrPO46XWDdK0FUbkT0S 998Qp1G9XHJ40hkQW5UZ1og= X-Google-Smtp-Source: AK7set8cY6+CxUqEghhyFB63kCKwBNLY2ni9kzAAT4tsO7Keznn/6twVeNDYb1aAH4QrYdKNFvtbRA== X-Received: by 2002:a17:90b:33cb:b0:230:7a2b:da9b with SMTP id lk11-20020a17090b33cb00b002307a2bda9bmr2599335pjb.34.1676904191379; Mon, 20 Feb 2023 06:43:11 -0800 (PST) Received: from localhost ([2400:8902::f03c:93ff:fe27:642a]) by smtp.gmail.com with ESMTPSA id go6-20020a17090b03c600b00233afe09177sm1582464pjb.8.2023.02.20.06.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 06:43:10 -0800 (PST) Date: Mon, 20 Feb 2023 14:43:03 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Mike Rapoport Cc: lsf-pc@lists.linux-foundation.org, linux-mm@kvack.org, Aaron Lu , "Kirill A. Shutemov" Subject: Re: [LSF/MM/BPF TOPIC] reducing direct map fragmentation Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9E36B1A000A X-Rspam-User: X-Stat-Signature: oicoani8yjaue91qti7gf1er7wq8mgai X-HE-Tag: 1676904192-342601 X-HE-Meta: U2FsdGVkX18zU0Rm0PB8yVBOMe+G0kzdGzDywmhsGQjWW+QMFLB7DSDLfGK9ok3yAgmAOHlN3bfQxiCE332oFnJqMyFgA8Rkwv0RmNI1rRumHvSgL/RWqkgZsS3KOil+TQuJpc6OIUqKleiexvz96Lgujk71NCyzPgqySrUUUIlbehIgaBreVehowOWR6YdL5EOeMuI7natB5/L2NsuQULA1xHJl7flBwDtFsYrKwKUBUJouLkQGNMQMcJz1VRzE3sXYSJBwZoI+kPaUKGtjyigLQ35TG1RwtB4EyG2hOc350GY8wRMH908GKygoFLOwrJhYBZOwG6E+9RsuMX+3wd+8FHZMYIFB0//E2brZCom2LUTGpfCSjscBZOder+CapAJzUX1XDgV3U1RPfLj/XGTY9HZ//jnomfMJgka2QfC3Yd6LVleLEf31F3s9g2p9Nj+PgxZv5+vrckZyHHdAf/n8t6RnitkuYPK1WCWR1FaTcGr4Sh9DhRqDE28t0pgDGkZcUUI/iuF4UdOx6SF5gYZF47Bc/7uYFoGFz7QdVqyNdiHoCHWyeegp6ePu5SGoep5BDBwitkhc9MBVi2ToxKrBM3WWnPUeAySipVQZkrJqwrmT7jeyU0lqFv/ak9tKTFnssG3fzf2uF/ItREOPqSFJaot9I4YkUtEL09/D2IKiOPCKG3sOK6gjVOptMAwaLs2Tsh+Fep3Ql304QA9ur5HcYgoD85ys6mrA797VuPDk81pFSTFbf2OUjRClv0ljVGsg6CKwvFqZfDu9WZ/t9KQsVJt5qTwyBqpSEV+wVShmw4m0ugiQxMe/oQvzLoHfGjT5z+9U7tUX+aV53WJx3bhpl/FR9s1ffjYD/nu2hBHMtk+2pSZpLDdnRlznmVxExpJGM9SVw6L+l9QDNd2GmzKqc5NNp0ymWXgubm1Yzhc4isdMR3f6IPnq9ZcEaONXMdSRv7i1U/gkp1c8C9Y YWRzwWlU 2B74kluUh43C/UrCLS0zXLPRBPq0u/v9ufIkexBnqVxPd9y1HZq07HzAhPG2zwYtSm1Kafk0y0CrMjl5qDP0wwTVDmvSofgBe9afu3URk4+TQMwD6MwnlawVJXj9ItUOfxScSD/BSwBWc5TyKj7gt7HA1TpIC74884YINOa9cVgLQp5pomcz+V4jSZ3qE2sYL+cMV/P3y+FpeKuwjjqKbsQFFbOHpIH5IiWYhQvrRoB/SX9POR/8NwBvf+6ZYQQKVxXZAsO9L+vQaiIQQZFo2GKuTcjI5ZU/ifHTXvflRq7fYw5soO1i1M1ik+QMRL5P8thI0ulEn5tY2sCIO3cVe6sFCQESnmzvulO1StS92qtE3TaykKgxw8jzQX2OMsR590tLNjp5KzHz9Me/MYdVXXIwnSS8bOl6HovtsU40K2o3A5U2oANUubKO4vlgaD7l/Kt7Q6wm/mKHnrNxzFs3kXTPeFxC4zRJ/GLIb/Oxty7EZqAABhBUDSI675Xx6uWEwCMeGBdKa87dggduxZcwHQACr+LeiSDjyvZnh5QgIoTdU+apUFCMCCiVbdZHLqMg1QYOq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Feb 19, 2023 at 08:09:07PM +0200, Mike Rapoport wrote: > On Sun, Feb 19, 2023 at 08:07:59AM +0000, Hyeonggon Yoo wrote: > > On Wed, Feb 01, 2023 at 08:06:37PM +0200, Mike Rapoport wrote: > > > Hi all, > > > > Hi Mike, I'm interested in this topic and hope to discuss this with you > > at LSF/MM/BPF. > > > > > To reduce the performance hit caused by the fragmentation of the direct > > > map, it makes sense to group and/or cache the base pages removed from the > > > direct map so that the most of base pages created during a split of a large > > > page will be consumed by users requiring PTE level mappings. > > > > How much performance difference did you see in your test when direct > > map was fragmented, or is there a way to check this difference? > > I did some benchmarks a while ago with the entire direct map forced to 2M > or 4k pages. The results I had are here: > > https://docs.google.com/spreadsheets/d/1tdD-cu8e93vnfGsTFxZ5YdaEfs2E1GELlvWNOGkJV2U/edit?usp=sharing > > Intel folks did more comprehensive testing and their results are here: > > https://lore.kernel.org/linux-mm/213b4567-46ce-f116-9cdf-bbd0c884eb3c@linux.intel.com/ Thanks! Hmm it might not be best choice to unconditionally merge 2M mappings to 1G a mapping. (maybe should be controlled via a boot parameter or something) > > > My current proposal is to have a cache of 2M pages close to the page > > > allocator and use a GFP flag to make allocation request use that cache. On > > > the free() path, the pages that are mapped at PTE level will be put into > > > that cache. > > > > I would like to discuss not only having cache layer of pages but also how > > direct map could be merged correctly and efficiently. > > > > I vaguely recall that Aaron Lu sent RFC series about this and Kirill A. > > Shutemov's feedback was to batch merge operations. [1] > > > > Also a CPA API called by the cache layer that could merge fragmented > > mappings would work for merging 4K pages to 2M [2], but won't work > > for merging 2M mappings to 1G mappings. > > One possible way is to make CPA scan all PMDs in 1G page after merging a 2M > page. Not sure how efficient would it be though. That seems to be similar to what Kirill A. Shutemov has been tried. He may have opinions about that? [3] https://lore.kernel.org/lkml/20200416213229.19174-1-kirill.shutemov@linux.intel.com > > At that time I didn't follow more discussions (e.g. execmem_alloc()) > > Maybe I'm missing some points. > > > > [1] https://lore.kernel.org/linux-mm/20220809100408.rm6ofiewtty6rvcl@box > > > > [2] https://lore.kernel.org/linux-mm/YvfLxuflw2ctHFWF@kernel.org > > -- > Sincerely yours, > Mike.