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 DEF5AC433FE for ; Tue, 26 Apr 2022 08:55:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 749636B0075; Tue, 26 Apr 2022 04:55:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F9526B0078; Tue, 26 Apr 2022 04:55:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59A206B007B; Tue, 26 Apr 2022 04:55:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 4B8156B0075 for ; Tue, 26 Apr 2022 04:55:01 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2D03920CD1 for ; Tue, 26 Apr 2022 08:55:01 +0000 (UTC) X-FDA: 79398420402.02.8CB1959 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf28.hostedemail.com (Postfix) with ESMTP id 07DB1C003D for ; Tue, 26 Apr 2022 08:54:53 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id i24so17363408pfa.7 for ; Tue, 26 Apr 2022 01:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lOo0L794BWkmgoUAfFFja7lP5ln4effh0J1pKS9JIe8=; b=Oz/O5YqdhSiccdxQnKXdl92bbBnGi2QG57Ydixn9DIGzWjyg46FMF4y8jZV3vMjrvb RU92LcOdnJh0PSlC2jRgWMAIdapIAtSfO/VAaHjx+Wz7hN9iMmx5FRy39aTl1g98YOY+ pHvHA0KcI+ZOl8bkABfJi1raJzG3+UGJVrddENYPrw/vw/krFxUOnULJrHMApCXdnBjd A8sr1jlJaY8lwj8vqxd/pAy3HF7kGtcXGrlc3jBIY4tXYyXqMmAZoIBmwX0O7+wJ1kF5 LyJUMX0GCIKDHC5b3TGqgtKy4UEMQipwniv3ra0G1I7EsNcr+UuilfsmL0ds+Z8iyptz QaKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lOo0L794BWkmgoUAfFFja7lP5ln4effh0J1pKS9JIe8=; b=JXi3ZKRKrjFJTpucRZgISzQp+ph2Twhgj15HfJ+PIezpVe4qgfHN/ipk/I/O7bviPC GYL5KU8x6g1ghl0xS+hteWyrWsKBfxbaBJuGI/B+Ab2oEeh08mQlsiMyy9M5m66r2xNd sLJL0X0Bp7kqOxOz7QrSx/fxaGWYD0HFYrZmAxJfRqOnVCCshWM6IBPWSFPzT3KDxhG+ mofA4DzPwk206ps68YbyXlCDmDKKs8osk/foHw6vrX83HfuR/nOf5BS7q7eFx1QlQcEA fIwLplO3JeHpX6gVE5ec7JvMAkNHwy1ZKJNOcSnHRgw+9oFi03FtY/MTwIX8xoecOgIx 0w3Q== X-Gm-Message-State: AOAM531FbMHcUaDxRdw28fS/V3hhlNMS3TGTEp3t9jQ5bFsPEIl2r2Qn 7zeg1Lifnpl7XdOXp5WvqoA= X-Google-Smtp-Source: ABdhPJwQhfzD+OhQDXxPEvP1sDbC33kcc4vuFOQHUI1tB7I8vWYKQ2aVV6Lo3DGGltzvfMrfSFlPew== X-Received: by 2002:a65:5a02:0:b0:39d:9d69:25fe with SMTP id y2-20020a655a02000000b0039d9d6925femr18843708pgs.140.1650963299743; Tue, 26 Apr 2022 01:54:59 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id o4-20020a625a04000000b004fdf5419e41sm14354794pfb.36.2022.04.26.01.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 01:54:57 -0700 (PDT) Date: Tue, 26 Apr 2022 17:54:49 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Mike Rapoport Cc: linux-mm@kvack.org, Andrew Morton , Andy Lutomirski , Dave Hansen , Ira Weiny , Kees Cook , Mike Rapoport , Peter Zijlstra , Rick Edgecombe , Vlastimil Babka , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [RFC PATCH 0/3] Prototype for direct map awareness in page allocator Message-ID: References: <20220127085608.306306-1-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220127085608.306306-1-rppt@kernel.org> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 07DB1C003D X-Stat-Signature: nz3p5u6ak955hoawa1xnmjg3h7dnqr7t X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Oz/O5Yqd"; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1650963293-998261 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 Thu, Jan 27, 2022 at 10:56:05AM +0200, Mike Rapoport wrote: > From: Mike Rapoport > > Hi, > > This is a second attempt to make page allocator aware of the direct map > layout and allow grouping of the pages that must be mapped at PTE level in > the direct map. > Hello mike, It may be a silly question... Looking at implementation of set_memory*(), they only split PMD/PUD-sized entries. But why not _merge_ them when all entries have same permissions after changing permission of an entry? I think grouping __GFP_UNMAPPED allocations would help reducing direct map fragmentation, but IMHO merging split entries seems better to be done in those helpers than in page allocator. For example: 1) set_memory_ro() splits 1 RW PMD entry into 511 RW PTE entries and 1 RO PTE entry. 2) before freeing the pages, we call set_memory_rw() and we have 512 RW PTE entries. Then we can merge it to 1 RW PMD entry. 3) after 2) we can do same thing about PMD-sized entries and merge them into 1 PUD entry if 512 PMD entries have same permissions. [...] > Mike Rapoport (3): > mm/page_alloc: introduce __GFP_UNMAPPED and MIGRATE_UNMAPPED > mm/secretmem: use __GFP_UNMAPPED to allocate pages > EXPERIMENTAL: x86/module: use __GFP_UNMAPPED in module_alloc > > arch/Kconfig | 7 ++ > arch/x86/Kconfig | 1 + > arch/x86/kernel/module.c | 2 +- > include/linux/gfp.h | 13 +++- > include/linux/mmzone.h | 11 +++ > include/trace/events/mmflags.h | 3 +- > mm/internal.h | 2 +- > mm/page_alloc.c | 129 ++++++++++++++++++++++++++++++++- > mm/secretmem.c | 8 +- > 9 files changed, 162 insertions(+), 14 deletions(-) > > > base-commit: e783362eb54cd99b2cac8b3a9aeac942e6f6ac07 > -- > 2.34.1 > -- Thanks, Hyeonggon