Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2940051imw; Sun, 17 Jul 2022 21:29:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7kOgTIfCFlzAgyp4vwfY5Ct/QKEoK+Vjm9UP/HSBTsvnt/F/24ObqOV5NdjtHv6359ju9 X-Received: by 2002:a17:90b:3506:b0:1f0:81a:6477 with SMTP id ls6-20020a17090b350600b001f0081a6477mr36591628pjb.46.1658118557406; Sun, 17 Jul 2022 21:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658118557; cv=none; d=google.com; s=arc-20160816; b=K+Cy9KARTtil4O+jz/NMf8JdcfzDNjn4vLWflJzBgF8QAnNBsRdjEQ4xmVZMutHbT6 TqiW5RSSomCE2R3Nh1LmXBZ0o1ed+bQ4mZ8LFycRzODyHx2npuvqLXBHLvstb79mNe3X LbGgFknjYwqzn4lDFWf0m37k2SsRauWCt2I4Y19kie7YwZ8IOT1krrpPFvV8YRPT1It0 JXu/1CMpSHbW4oVluWjuJyHAyz1LX5a3Z6GLd7WO/OAEhq761++BroucXTHE2i7+R6nw FR6fM0xZZNZuA/Vbi0GHrJyyUXvHshD06r2jGw3hDqT4IuaPiDK75l2t35hZfmqFzavE 9l6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EsNHa5a7SYRE73Woad1Pm7o9hAag7TsYX0J/jHgYB7o=; b=ThGW/6jkbSVpu+MTC8JZ/nadGOZKhEuSMhMf42fxhf7FiQgCj9UmK6z8fHX4oqehOa FGsSGISouxNxOdJ7owSQlGB4J6QyHw+s0wlM0WR5HhuoNgx2cozZCGUGUDpSmdGVsVLD FIQY3B8pXsW4MdatXAbiycffEot1J9Lp7jrW27I1kMDL+B6cDnFi2lToOvHzP2H9BNzE 4337h/YFMHOSmwP/uU95Tt3ofmZM7K5WXToJNoml2fPp+QGX7BxJ6XzQd0XcXcs6Sj0P Rh848rJDP+91VShpEUi4JodLctOy3n27NgI4w2w/jJ11Gayq68mU4LgmsxQMiwFKukgX F+hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=g4VJ8tJf; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020a656417000000b00419b274ca1csi14177350pgv.601.2022.07.17.21.28.55; Sun, 17 Jul 2022 21:29:17 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=g4VJ8tJf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231509AbiGREEe (ORCPT + 99 others); Mon, 18 Jul 2022 00:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiGREEd (ORCPT ); Mon, 18 Jul 2022 00:04:33 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B69B411C37 for ; Sun, 17 Jul 2022 21:04:28 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id n185so6389842wmn.4 for ; Sun, 17 Jul 2022 21:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EsNHa5a7SYRE73Woad1Pm7o9hAag7TsYX0J/jHgYB7o=; b=g4VJ8tJfoUHwr0f7YDkQKkA2v6ULPwzVFzxffb3/pOBGZWeRc9VcpfIi8GgVh01apL EGkJik7CdGhR9BPWa8mqiVzx5QYd+vhhGjykJBI6EjIqzuxCyhDcApT2gdAhndSkjmOw Y7lydZUx1es+7aBOqRlgDjEGmQRUYTYX+YnrfmwWmdUkf1v5HHFLlFcVogRKXs4Vs9hj n8grMRfAXob3+G2SMsba001Dfuvtk27dCCVgZrkl2Xg8piE993Ccs7hvVSfUJFX6I87C ZGxeMqyKG9exBMjSphCcDQKjtwHGfSlKZz9HTxj9Cj9ApFho6snHsD+u7VXjKwpwzqJc OzPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EsNHa5a7SYRE73Woad1Pm7o9hAag7TsYX0J/jHgYB7o=; b=MQXv3ks1dbFe4EJ2ejpj3xiJSE79DzWI+qu7eDJnxjWamlxJ3Eh3LKpPmuBrHgneyR R3LUP8M2uwanlyddjzTkdhm7yK66rpBgZSx8nSVKvowBsF51U7ICdR3g1aMyuHd4kb79 6ELFurxQWYsp56dzi1ryX2LkyztCt2vDGsRL0ix3eNPSgqCmDSxr2JWXVsowRLjb7ZYI 0OX4G+rnHiU3eqrgf8IPUa+iToXCsWp/k/PpCcQPP1gi9fZaDbP2HbPe5iM7NjjdSEEL NG1AWj4UTxAo5cZ1+j9YRUaEFopdJ0gzK2qGYE9u8zdmxOBAl+OQxpW2Beo6hu0BtoeD /Btw== X-Gm-Message-State: AJIora9jYjmam9L/hNQFo3on7zo0cCJxjOmcBR1tt7VKUwjzfAt8t846 1CBTqDPubHUh+65pVYvfd3uAPPrXQM5lyxidm5k2pA== X-Received: by 2002:a05:600c:3caa:b0:394:8fb8:716 with SMTP id bg42-20020a05600c3caa00b003948fb80716mr30056082wmb.105.1658117067083; Sun, 17 Jul 2022 21:04:27 -0700 (PDT) MIME-Version: 1.0 References: <20220707145248.458771-1-apatel@ventanamicro.com> <20220707145248.458771-2-apatel@ventanamicro.com> In-Reply-To: From: Anup Patel Date: Mon, 18 Jul 2022 09:34:15 +0530 Message-ID: Subject: Re: [PATCH 1/5] KVM: Add gfp_custom flag in struct kvm_mmu_memory_cache To: Paolo Bonzini Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Alistair Francis , KVM General , "open list:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv)" , linux-riscv , "linux-kernel@vger.kernel.org List" , Atish Patra Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Hi Paolo, On Wed, Jul 13, 2022 at 6:57 AM Atish Patra wrote: > > On Thu, Jul 7, 2022 at 7:53 AM Anup Patel wrote: > > > > The kvm_mmu_topup_memory_cache() always uses GFP_KERNEL_ACCOUNT for > > memory allocation which prevents it's use in atomic context. To address > > this limitation of kvm_mmu_topup_memory_cache(), we add gfp_custom flag > > in struct kvm_mmu_memory_cache. When the gfp_custom flag is set to some > > GFP_xyz flags, the kvm_mmu_topup_memory_cache() will use that instead of > > GFP_KERNEL_ACCOUNT. > > > > Signed-off-by: Anup Patel > > --- > > include/linux/kvm_types.h | 1 + > > virt/kvm/kvm_main.c | 4 +++- > > 2 files changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > > index ac1ebb37a0ff..1dcfba68076a 100644 > > --- a/include/linux/kvm_types.h > > +++ b/include/linux/kvm_types.h > > @@ -87,6 +87,7 @@ struct gfn_to_pfn_cache { > > struct kvm_mmu_memory_cache { > > int nobjs; > > gfp_t gfp_zero; > > + gfp_t gfp_custom; > > struct kmem_cache *kmem_cache; > > void *objects[KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE]; > > }; > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index a49df8988cd6..e3a6f7647474 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -386,7 +386,9 @@ int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min) > > if (mc->nobjs >= min) > > return 0; > > while (mc->nobjs < ARRAY_SIZE(mc->objects)) { > > - obj = mmu_memory_cache_alloc_obj(mc, GFP_KERNEL_ACCOUNT); > > + obj = mmu_memory_cache_alloc_obj(mc, (mc->gfp_custom) ? > > + mc->gfp_custom : > > + GFP_KERNEL_ACCOUNT); > > if (!obj) > > return mc->nobjs >= min ? 0 : -ENOMEM; > > mc->objects[mc->nobjs++] = obj; > > -- > > 2.34.1 > > > > Acked-by: Atish Patra I have queued this patch for 5.20. Please let me know if you are not okay or need changes in this patch. Thanks, Anup