Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2887351rwd; Fri, 19 May 2023 11:31:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5g07Y/wMo/IghZwXGV0eUE5Um9UgDz74gasr0huNQ9RfolvjAj00OfrdRWXoJLaa89wzOU X-Received: by 2002:a17:90a:db0a:b0:24e:596:624f with SMTP id g10-20020a17090adb0a00b0024e0596624fmr2629745pjv.22.1684521080255; Fri, 19 May 2023 11:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684521080; cv=none; d=google.com; s=arc-20160816; b=NxPAWGmrRsqd9Dk3yDwQFBt33TOXmm2YLBj780SQT6BtbUvkBjfsi9h4JdpuovqGfS PW47dLLtuhA/b3MZYqeSEbgAR5RjeXvVmJD9JyUMPqzZ8PqXtrSq1n9bxQyZ6XQlszMq W1tNAuV6mxWs/28Lg32PohFEq0GBYV3PzULLfmgUHfSfWyG2l4ujvFxdhd+QZJBnMRKh Jn46HrZJgtyvnIX5Tii9jBLKKqbTbSP70bNvLFRUFX16lUBnyy5HFQJMtJJtoV9Njg/u JIuEhZpJ+Wa3yGj7zJzWMAo3yobITdcmRlBTN+WH/6IGG4NpHn+YBvuGRhP/i8d9+FQI IzLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=UkvqDfyMOLrjy8YMY1wwRgMIQfqQZGbB8xX3NIFQuJ8=; b=UMYMeTsJWdoKRaUOwQD82svonGHMqcWXY3hfPIcN3XVDETcrE+JV0X2TqhAXPEPEuX Xsgrn1VW/lZDGawo86jNxXIafB3BysFGm2npEybniNNTQYdO9dZLA70dY8rCEFpJ07Wz r9UIysKnlhdW49FpBWaNXysTfcTioSUuoMNoiUqpNXHqmWBnhfFYpbmMF/g9LC1WBvWR mzPb211L4UyIejbIh2UDmzj8iJAj96cXitnhbGAJ3yOAGLYt+eMGG4azdM5NoRi4F4s1 qez/PAzcVj5lHoT8B+ya0ePLXp9osi43qF24stohHS+8V53ds/hON7jN/wb5earFiy4c bN9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=EHWVv93H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m132-20020a633f8a000000b00518f82d7053si34192pga.493.2023.05.19.11.31.05; Fri, 19 May 2023 11:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=EHWVv93H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbjESSZ6 (ORCPT + 99 others); Fri, 19 May 2023 14:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjESSZ5 (ORCPT ); Fri, 19 May 2023 14:25:57 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C6D3E1 for ; Fri, 19 May 2023 11:25:56 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba8696637a7so6861071276.3 for ; Fri, 19 May 2023 11:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684520755; x=1687112755; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UkvqDfyMOLrjy8YMY1wwRgMIQfqQZGbB8xX3NIFQuJ8=; b=EHWVv93HNkwFD6Rzv38Ipc2B9rPBD1UDSNb25aEyGm9tgrL4HAfKR3FhP4mF0gDZ8o 5akGYCEZHakPY7q+34PKZr+wjUxJKbOWkHSdmCIF9EthXaS0GE1aeTDaAYg74+n8LxZv NrNY0cT19gsI9F6xDoZFfVqJL3/PXEZm7iHMz8EEbdrZb3BVlRolZpZs2icBr5OUNum5 NS6M57Pod3yr/sG/iNpxrle6ypJpM2UH+leYpSYYesmxJnETM/FgFp+u2mEeUpZlkVpR gVvuRxOcV30/Oziq9eKB/d6UWnrG6nSzoKyR8Y2BOsFA/g06gQPoCPP9LQW1NpKMIWBr bE6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684520755; x=1687112755; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UkvqDfyMOLrjy8YMY1wwRgMIQfqQZGbB8xX3NIFQuJ8=; b=MAikf9SOX62Yv3JNURu3oUUEG31NBadlQfQUZ9fcZRpIrI6fl9gv/9kT571ogzz92N wxo/O7rnKRQ6E9G0uLa5y0aUtUm3Ij2LyWtDXfaN3ewX4GGa5L36C9aaW430be0XF/GQ gyeqUzDs5NK00YVGOaTyiIJpW19LcSUe6B1FyXWNp/RZNX7N4QdIjqaJBJJdS3Vy5Y+i vZsWlALmnAokMQvQ1bklQTQ7XrXC0gF4BRG270VzV2YNoAB4Uzu/hDoxPnnra9S22b3C bW/ABDpQu9SG3A4nFHs2cDfsp7dj+joQjerdRILN4btVJjnKB2dDPFiJBo/vHvMXFJ2z W9wg== X-Gm-Message-State: AC+VfDyZQ1FVm5Tfjf9BKSD5nIR2xTkZ79CfC1gmcd2/ZzEjql95Jaa3 AXGTXN7LPBesC/kG5MHeRPeMIhCiWjs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:8402:0:b0:ba8:797c:9bc7 with SMTP id u2-20020a258402000000b00ba8797c9bc7mr1655166ybk.11.1684520755427; Fri, 19 May 2023 11:25:55 -0700 (PDT) Date: Fri, 19 May 2023 11:25:53 -0700 In-Reply-To: <20230519162432.GG4967@kernel.org> Mime-Version: 1.0 References: <20230308094106.227365-1-rppt@kernel.org> <20230519162432.GG4967@kernel.org> Message-ID: Subject: Re: [RFC PATCH 0/5] Prototype for direct map awareness in page allocator From: Sean Christopherson To: Mike Rapoport Cc: Rick P Edgecombe , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "tglx@linutronix.de" , "song@kernel.org" , "dave.hansen@linux.intel.com" , "vbabka@suse.cz" , "x86@kernel.org" , "akpm@linux-foundation.org" Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 19, 2023, Mike Rapoport wrote: > On Fri, May 19, 2023 at 08:40:48AM -0700, Sean Christopherson wrote: > > On Thu, Mar 09, 2023, Mike Rapoport wrote: > > > On Thu, Mar 09, 2023 at 01:59:00AM +0000, Edgecombe, Rick P wrote: > > > > On Wed, 2023-03-08 at 11:41 +0200, Mike Rapoport wrote: > > > > > From: "Mike Rapoport (IBM)" > > > > > > > > > > Hi, > > > > > > > > > > This is a third attempt to make page allocator aware of the direct > > > > > map > > > > > layout and allow grouping of the pages that must be unmapped from > > > > > the direct map. > > > > > > > > > > This a new implementation of __GFP_UNMAPPED, kinda a follow up for > > > > > this set: > > > > > > > > > > https://lore.kernel.org/all/20220127085608.306306-1-rppt@kernel.org > > > > > > > > > > but instead of using a migrate type to cache the unmapped pages, the > > > > > current implementation adds a dedicated cache to serve __GFP_UNMAPPED > > > > > allocations. > > > > > > > > It seems a downside to having a page allocator outside of _the_ page > > > > allocator is you don't get all of the features that are baked in there. > > > > For example does secretmem care about numa? I guess in this > > > > implementation there is just one big cache for all nodes. > > > > > > > > Probably most users would want __GFP_ZERO. Would secretmem care about > > > > __GFP_ACCOUNT? > > > > > > The intention was that the pages in cache are always zeroed, so __GFP_ZERO > > > is always implicitly there, at least should have been. > > > > Would it be possible to drop that assumption/requirement, i.e. allow allocation of > > __GFP_UNMAPPED without __GFP_ZERO? At a glance, __GFP_UNMAPPED looks like it would > > be a great fit for backing guest memory, in particular for confidential VMs. And > > for some flavors of CoCo, i.e. TDX, the trusted intermediary is responsible for > > zeroing/initializing guest memory as the untrusted host (kernel/KVM) doesn't have > > access to the guest's encryption key. In other words, zeroing in the kernel would > > be unnecessary work. > > Making and unmapped allocation without __GFP_ZERO shouldn't be a problem. > > However, using a gfp flag and hooking up into the free path in page > allocator have issues and preferably should be avoided. > > Will something like unmapped_alloc() and unmapped_free() work for your > usecase? Yep, I'm leaning more and more towards having KVM implement its own ioctl() for managing this type of memory. Wiring that up to use dedicated APIs should be no problem. Thanks!