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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13870C433EF for ; Thu, 31 Mar 2022 22:24:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242434AbiCaW0D (ORCPT ); Thu, 31 Mar 2022 18:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242429AbiCaW0B (ORCPT ); Thu, 31 Mar 2022 18:26:01 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1628B193230 for ; Thu, 31 Mar 2022 15:24:13 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id bt26so1674461lfb.3 for ; Thu, 31 Mar 2022 15:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FP8sOgFMKdQHyzKTsWIeV2u7i9jzT+8IqNj2W9h0y6Y=; b=mgJpIhoRYTQaPKyD3ets4VfMCGuyuUERLeqqLiU6SYa8F/zYOQ+h8/g1J0qezFVtOK O9SUhLAx/Ggx5tyWGuHYOABMZhIskcWmon0TsLGOFa2UpeiysS8LHeBZHAL6LGKFlLwh fhbO10znZh8RNnVHLo/dtXGYwPnlRcoIIZyVp0/wY+x6gBkYTdqjvOIjvfrsmOxR18GC futWvmXYez+5heCAfp/zr9jgJzzw79AeOjnRIbDFSupqzBYfYkrEyaUE2EpSfF0iMQov PHDqvCl8rCy0XQj9zBoaT1ikVu3p0u3FdN1Ni1zcCOZ2Q23HUkirni5TmfR3nlFTd/Z8 02qg== 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=FP8sOgFMKdQHyzKTsWIeV2u7i9jzT+8IqNj2W9h0y6Y=; b=R+lBKmGm2ckL+PbEBY/ceEnTzYU6+kv2PgW1j3z0wer2sUoQIOnwoV1TbGpYU3BFoB 9sL6fGtamC5z5KVAqoBk9HTFuhFAPC5uGJ8HiXKOIR3aXC+/a/uZKqRDDoSt6KS7n5YT 0LaSdVXEUNTGBSaN710EMy6f20VyiIktStBvTIGGjMBqWWHW0m5YJlKhfUmYRK9oRk/Y d+KvDJPq8NgaVVi+0dE64w5sWlfsUOc72U2utbV7pUiz5BoLmNbIqkR3rKYLdj5qZtkQ P9KQczmePGobrvWEFCrw6HaR7myMzR04k7CvTsSVWJJe3z3LJzbqu7xTLB7PVDdmXobc VhPg== X-Gm-Message-State: AOAM531SyA+VAvZhLHN3d9KlpWulvumluPr3mFJAHQwY2l2CnG1HWEge Oh65YSpkUA0rdUJfgDEqGG2W1c+twq/36pQec+3Od89fJEE= X-Google-Smtp-Source: ABdhPJw/vhxve7+6KTHW3YpBJoZ3JZrLnR/TtF1CNp+XFA/FgPzfWR/amGaUksAVYCKZi+H81bYWKN+lPht6SwO2tkE= X-Received: by 2002:a19:490f:0:b0:448:4bf8:6084 with SMTP id w15-20020a19490f000000b004484bf86084mr11842370lfa.537.1648765451129; Thu, 31 Mar 2022 15:24:11 -0700 (PDT) MIME-Version: 1.0 References: <20220330165510.213111-1-pbonzini@redhat.com> <0c830e36-fcf2-fab6-aed9-7b6a6736140f@redhat.com> In-Reply-To: <0c830e36-fcf2-fab6-aed9-7b6a6736140f@redhat.com> From: David Matlack Date: Thu, 31 Mar 2022 15:23:44 -0700 Message-ID: Subject: Re: [PATCH] KVM: MMU: propagate alloc_workqueue failure To: Paolo Bonzini Cc: LKML , kvm list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 31, 2022 at 2:34 AM Paolo Bonzini wrote: > > On 3/31/22 01:51, David Matlack wrote: > >> -void kvm_mmu_init_vm(struct kvm *kvm) > >> +int kvm_mmu_init_vm(struct kvm *kvm) > >> { > >> struct kvm_page_track_notifier_node *node = &kvm->arch.mmu_sp_tracker; > >> + int r; > >> > >> + INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); > >> + INIT_LIST_HEAD(&kvm->arch.zapped_obsolete_pages); > >> + INIT_LIST_HEAD(&kvm->arch.lpage_disallowed_mmu_pages); > > > > I agree with moving these but that should probably be done in a separate > > commit. > > Ok. > > >> - kvm->arch.tdp_mmu_zap_wq = > >> - alloc_workqueue("kvm", WQ_UNBOUND|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 0); > >> - > >> - return true; > >> + kvm->arch.tdp_mmu_zap_wq = wq; > > > > Suggest moving this to just after checking the return value of > > alloc_workqueue(). > > This is intentional, in case we have other future allocations, to avoid > having to NULL out the field in the unwind path. It's a matter of taste > I guess. Oh ok, that makes sense. I agree it's a matter of taste. > > >> + return 1; > > > > Perhaps return 0 until we have a reason to differentiate the 2 cases. > > Yeah, though I wanted to preserve the previous behavior. > > >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > >> index fe2171b11441..89b6efb7f504 100644 > >> --- a/arch/x86/kvm/x86.c > >> +++ b/arch/x86/kvm/x86.c > >> @@ -11629,12 +11629,13 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) > >> > >> ret = kvm_page_track_init(kvm); > >> if (ret) > >> - return ret; > >> + goto out; > > > > nit: This goto is unnecessary. > > True, but I prefer to be consistent in using "goto" so that any future > additions are careful about preserving the chain. Sounds good. > > Paolo >