Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2840847rdh; Mon, 30 Oct 2023 09:07:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPy4KP8mUA6QdijwIv3dcL5rgTlqRiIdsJTXNGEYM9dPdyQZT33fFFwpKatd2nqHFwelPq X-Received: by 2002:a05:6358:881f:b0:168:e479:58bc with SMTP id hv31-20020a056358881f00b00168e47958bcmr12806503rwb.16.1698682052760; Mon, 30 Oct 2023 09:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698682052; cv=none; d=google.com; s=arc-20160816; b=jsxCteSN/ojKKHjR980mPvawL6OLNEy7oEuoeTKHnVAXSO0zEeXN86I0FFnd7T/lpt eG3thpjdFNzqeGQbUVG5HxrS6p8weKpEN7Q0us1WIQbUNgmIj/lqU7aKUIN+Y15O0Y3J 37Jmqd4hDeoYE6aPRPNQVCULxjGTI1tnRzw13Hn4XTTAUzC0YLvU2eKHnv1Krto6bUtE nOmxvNoRfMs7r1j8GsJqovSd0ZbFO3hFOxwGxuDL7XqoxNOfqJnDQ1HT43o0RIH8d5oZ TQq19d8fyC5/mPRriLGHuY35Tfrad2Jq/RSnMeXy522sdroeiMpCTBRAu1zMcOfSeHTW v1VQ== 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=CYj9CzuAjK7WX2GIPL2L+DIVtRCWsgVm7uwhZjeF2lA=; fh=1ppcbYJOdR/rezLL5A3OGkQNPvMprjT9r91Z1rkjtZg=; b=xi/0GI+ohOqt+xCL/A5ftZztlw2mrH1gR1IGvIwuO8ixXLg2uFw2JKt6N5Mhx3Auy9 ONqPnY7C32ts4xKqp6i21oi6sKT1fY2jy5d1tbovYYkwCDfb7mGD1imhtSUI1jqfNcfy s4jqBumkX+y1x8vmR490n1UjuTrdZfol0pRCxY9+e63KPcMx4RgqucswhJCW4B9hgbgf ulJHvCDfHyht0hGDB41/ETIhuBpHngxFl2ED2BI+Hw/lbs7Oxv1GyQU5J0K//B+X88GU eUekEkzqtk5DXixFoBkxqHIT44zkMA6dNQBVei0Zh8aHn10LHEbLWKzBwEmdI8eGsGtn 82cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3eQEBVVJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q4-20020a656844000000b005a1d8816535si5161040pgt.5.2023.10.30.09.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 09:07:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3eQEBVVJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1495E805D39C; Mon, 30 Oct 2023 09:07:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233621AbjJ3QHX (ORCPT + 99 others); Mon, 30 Oct 2023 12:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232469AbjJ3QHW (ORCPT ); Mon, 30 Oct 2023 12:07:22 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC58C9 for ; Mon, 30 Oct 2023 09:07:20 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1cc42d3f61eso11957755ad.3 for ; Mon, 30 Oct 2023 09:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698682039; x=1699286839; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CYj9CzuAjK7WX2GIPL2L+DIVtRCWsgVm7uwhZjeF2lA=; b=3eQEBVVJW6qpJRwIuasDzGtyhpatmXjUjasnElIBF8WjDI+5ApsFJ1zlDBlWT/69TB PbTOHJinmlk+6aMVIH1rf63/lkKTsx0HNyXkcOGxLPBIKoLTzYcS4D+N1dBwkqdfsq/S yrUZOH4RT0MgkqHKkV9fo9/iJHC5KhS9aBgKJ5GC3Ehhb5WvIv5T2CWdFs5anHN3mu4N TuA4Z1ZZjrp9Qq2HjIs19K7Ul9Ov/A5B/bGpzVvmCJQKXDxhBNMpPGy8oagszu8qGOCM Sy9/BZQ01UDgphVn92xAZ3R44OHqqS2VIxjhPZ/H/x+68a9CrcENGbg1bva66PztNRjU oSLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698682039; x=1699286839; 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=CYj9CzuAjK7WX2GIPL2L+DIVtRCWsgVm7uwhZjeF2lA=; b=RA6pGUpuRh7yZhiMI0mNLz/UWaADQ98Hv51TnUShJlZVQonhVmHtyTyYufKWVsf6th gPetf9jIEJxyfmFS5BsetgGReiGXvXhs+2S7MjIeEm4Y86lXii7U5m01oH9gUYsf9JdK OhC5teYwnILHOcXXKQQN9GsylEXYXORDUgTXqnY1qh03M0LtDfNxNlom6f+U4bDB641B 6462IM32aqZAA5YYcf3OdiY/bno0T//cO2jfYb6tj1zZ5mpppqZqfpq4OEjHpdoP7fTM XOlQ3DWpMKhReqCZd4hm7LXTSC38uNZqu1QV/9Oe/Vv69SYXan7+C7jGhWvXLEl2eDw6 wxdg== X-Gm-Message-State: AOJu0YytOEhVD/Lne/iR7wpRJAmHVAx0M/tL3CH0HgRSx1n/ZelzArQk zfbioQCOlUHgT+dznkibROePHa+F+yI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:d887:b0:1cc:47d4:492c with SMTP id b7-20020a170902d88700b001cc47d4492cmr63679plz.11.1698682039706; Mon, 30 Oct 2023 09:07:19 -0700 (PDT) Date: Mon, 30 Oct 2023 16:07:18 +0000 In-Reply-To: <20231030141728.1406118-1-nik.borisov@suse.com> Mime-Version: 1.0 References: <20231030141728.1406118-1-nik.borisov@suse.com> Message-ID: Subject: Re: [PATCH] KVM: x86: User mutex guards to eliminate __kvm_x86_vendor_init() From: Sean Christopherson To: Nikolay Borisov Cc: pbonzini@redhat.com, x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 30 Oct 2023 09:07:30 -0700 (PDT) On Mon, Oct 30, 2023, Nikolay Borisov wrote: > Current separation between (__){0,1}kvm_x86_vendor_init() is superfluos as superfluous But this intro is actively misleading. The double-underscore variant most definitely isn't superfluous, e.g. it eliminates the need for gotos reduces the probability of incorrect error codes, bugs in the error handling, etc. It _becomes_ superflous after switching to guard(mutex). IMO, this is one of the instances where the "problem, then solution" appoach is counter-productive. If there are no objections, I'll massage the change log to the below when applying (for 6.8, in a few weeks). Use the recently introduced guard(mutex) infrastructure acquire and automatically release vendor_module_lock when the guard goes out of scope. Drop the inner __kvm_x86_vendor_init(), its sole purpose was to simplify releasing vendor_module_lock in error paths. No functional change intended. > the the underscore version doesn't have any other callers. > > Instead, use the newly added cleanup infrastructure to ensure that > kvm_x86_vendor_init() holds the vendor_module_lock throughout its > exectuion and that in case of error in the middle it's released. No > functional changes.