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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A830C3ABCC for ; Wed, 14 May 2025 12:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7u8W/CG3gSf5woBAkiFKaWojc/enVjyXw0QmfzYrdeQ=; b=ofwJgUuuv3IzaF rWwOb1zMmq241VWiDefVgsE8VlOpu/qJDkdwQGikLPsh8QtAkH3F3QZv57opqEbA3uXiZKZpmQjSE Eux+u+VnzMuiSEyYQpWGidcZJUyomRHROdOUuakNZCPuBCdGQf0pn502p+TfLUKvKhSq9zBAFYJNi 6zgnAYtC34Wjr5qTYS8rGzDJFbX2Ma/KCYlkuThqrMbWCQ4V17MqnBPBnayIbfo41dMLq1fmQdSnd oMIZ8KBzp5B8IIZ4JxsQd/13Cd9QXqeEPUgkKOI7fQA53nBt0axZio9yAT5ec/TYWSmLu3uJ2801V qANpI3Qhl/AdX5b5f0JQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uFB4I-0000000F141-1YuJ; Wed, 14 May 2025 12:18:38 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uF8Ut-0000000EgDZ-0epl; Wed, 14 May 2025 09:33:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4E5FB5C6443; Wed, 14 May 2025 09:31:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45060C4CEE9; Wed, 14 May 2025 09:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747215234; bh=001qyor2xDVXczQ1I1uPsfetah7D3sKu1ILOVywqFnk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oAqFqcpmzH/13hbR8m/oQ4XroGsKo3tle3aJJsWrsQtLYro2z+PLvjOsuG88n/OxJ 34FvuHxK9/XH2rEkDkqevKA3Zm4RLx3TeYfuRmhdCmm/8LPM9f2joGVL1/H9yAQ2w7 qw+hk6NEElGhiwaleELGFNnRJkOZ8sTl5xHlheBLypOX+6C8a5S5AV5fGR3Ea5F2Iz 3/OiHuAPYPcgR16yDChngd6pC8mELRDahRp+jzf2AFxHuz/0wOYB28RUt92XcHMVGT V5A4ofsYMhlnn1DcsOUps8IUWyew4W6IuckFhHB5U55kOM/su9P9yW9kj58iy2KjS3 ibRlwfrHxQdpg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uF8Up-00Ennz-DL; Wed, 14 May 2025 10:33:51 +0100 Date: Wed, 14 May 2025 10:33:50 +0100 Message-ID: <86o6vvfse9.wl-maz@kernel.org> From: Marc Zyngier To: Maxim Levitsky Cc: kvm@vger.kernel.org, Suzuki K Poulose , Jing Zhang , "H. Peter Anvin" , Sebastian Ott , Shusen Li , Waiman Long , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Bjorn Helgaas , Borislav Petkov , Anup Patel , Will Deacon , Palmer Dabbelt , Alexander Potapenko , kvmarm@lists.linux.dev, Keisuke Nishimura , Zenghui Yu , Peter Zijlstra , Atish Patra , Joey Gouly , x86@kernel.org, Sean Christopherson , Andre Przywara , Kunkun Jiang , linux-riscv@lists.infradead.org, Randy Dunlap , Paolo Bonzini , Boqun Feng , Catalin Marinas , Alexandre Ghiti , linux-kernel@vger.kernel.org, Dave Hansen , Oliver Upton , kvm-riscv@lists.infradead.org, Ingo Molnar , Paul Walmsley , Albert Ou Subject: Re: [PATCH v5 3/6] KVM: add kvm_lock_all_vcpus and kvm_trylock_all_vcpus In-Reply-To: <20250512180407.659015-4-mlevitsk@redhat.com> References: <20250512180407.659015-1-mlevitsk@redhat.com> <20250512180407.659015-4-mlevitsk@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mlevitsk@redhat.com, kvm@vger.kernel.org, suzuki.poulose@arm.com, jingzhangos@google.com, hpa@zytor.com, sebott@redhat.com, lishusen2@huawei.com, longman@redhat.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, bhelgaas@google.com, bp@alien8.de, anup@brainfault.org, will@kernel.org, palmer@dabbelt.com, glider@google.com, kvmarm@lists.linux.dev, keisuke.nishimura@inria.fr, yuzenghui@huawei.com, peterz@infradead.org, atishp@atishpatra.org, joey.gouly@arm.com, x86@kernel.org, seanjc@google.com, andre.przywara@arm.com, jiangkunkun@huawei.com, linux-riscv@lists.infradead.org, rdunlap@infradead.org, pbonzini@redhat.com, boqun.feng@gmail.com, catalin.marinas@arm.com, alex@ghiti.fr, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, oliver.upton@linux.dev, kvm-riscv@lists.infradead.org, mingo@redhat.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250514_023355_278041_886038AA X-CRM114-Status: GOOD ( 18.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, 12 May 2025 19:04:04 +0100, Maxim Levitsky wrote: > > In a few cases, usually in the initialization code, KVM locks all vCPUs > of a VM to ensure that userspace doesn't do funny things while KVM performs > an operation that affects the whole VM. > > Until now, all these operations were implemented using custom code, > and all of them share the same problem: > > Lockdep can't cope with simultaneous locking of a large number of locks of > the same class. > > However if these locks are taken while another lock is already held, > which is luckily the case, it is possible to take advantage of little known > _nest_lock feature of lockdep which allows in this case to have an > unlimited number of locks of same class to be taken. > > To implement this, create two functions: > kvm_lock_all_vcpus() and kvm_trylock_all_vcpus() > > Both functions are needed because some code that will be replaced in > the subsequent patches, uses mutex_trylock, instead of regular mutex_lock. > > Suggested-by: Paolo Bonzini > Signed-off-by: Maxim Levitsky Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv