Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1791207lqm; Fri, 3 May 2024 06:48:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVZac/4CPtK2HqgqTIY45sPO6oSswUAjb/MZv1ylNd9sGURHDGTyDnDQHdFY1vqDcZD6HGjeWM+YBYN+r9BrPn3UTnqd15jrEYToZ2erg== X-Google-Smtp-Source: AGHT+IFdyImUMAlG/S6odPDZOMGilJSQxyGhmu/yAjbPlNaOE3joC2SdN5TF+78bT62BsthyYpZX X-Received: by 2002:a05:620a:1b86:b0:790:c7f6:59a0 with SMTP id dv6-20020a05620a1b8600b00790c7f659a0mr3211447qkb.1.1714744088025; Fri, 03 May 2024 06:48:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714744088; cv=pass; d=google.com; s=arc-20160816; b=tDf4ytqoUCbVXe2sY/Ix9xKQRyT5IkX3jRTdw6c39nI0BvAVx/n17REcTtIuFeVw98 6DLpb3SFkY6F7k/Ob6ghb2K7QPJIgqit1laBYhoa9uldKr8nd0xJiXkqR3lvdTz18gso DhzME9jGVbhghdxa66/gvmKIMTuOB+BONDwEIxH+9dDDHdacrop3jgCuAQ1/5y/5a86J lwIE5OAL4fitR/EZ/NGv+O86U4J2B65QEupurr0hSq2YFpEOXTZqG55blI+BBwV4jPwF SGz7c9NKtAPndO4dZGXkJsNMAn8hyKNsRdFj0Shh1OX5WYOSrZbE1J8Ep27y9FsghgSZ g56g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=SLlrQkd2iXanI/kW9JruqRjjOcTmn5fEnvoJmg8IxSo=; fh=VGL6oprXZRlFmafJ29Q9RsVYywD2dFkC+USQkIy/+nw=; b=NAVhglqJX1/0v2UGS/D1vcInIhrQIYf0cZ8BbYYTAesbxUrFXehIbx8ThqSsEMsu1S jgRhuNAiO7m5qoLCP9ZxGfHWipA02d1PekPw0/A7a8ZbHdvq6Q4uC1z/VIfkXV+ZbDnP L2MYdUNiPIhCcFP5Pkm+74QulDJgOUOqaEUeOPl4M8opf1p/Q2aufIrQAHN77WXqjnMu JmkHVxz1CGueWlWJcdIBM8nN97nG7z7j73AUabJmE18i6HIo9AqZqdmDx6NZMkOty1li HjG1goALzT//bRBMIL2r82qZQpJn9MX0adCJE2kAifNnOCuUrM7A57icgtLTfaM/gteO 9UQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm1 header.b=moxrLXde; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=LZ9LVyuZ; arc=pass (i=1 spf=pass spfdomain=shutemov.name dkim=pass dkdomain=shutemov.name dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-167722-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167722-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f9-20020a05620a280900b0078ec0e16362si3441633qkp.105.2024.05.03.06.48.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 06:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167722-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm1 header.b=moxrLXde; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=LZ9LVyuZ; arc=pass (i=1 spf=pass spfdomain=shutemov.name dkim=pass dkdomain=shutemov.name dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-167722-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167722-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id ACB621C22A0D for ; Fri, 3 May 2024 13:48:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97769153BF3; Fri, 3 May 2024 13:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shutemov.name header.i=@shutemov.name header.b="moxrLXde"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LZ9LVyuZ" Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A448153BD1; Fri, 3 May 2024 13:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.150 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714744080; cv=none; b=Xd5QHpPNr1Rd+TZ7qzCFcIpnBlK07nEMxgfKNtma6nGDLDHrWaThU2tCQmfI0rUfuHOawGGJ28B3cwOhdhN1D5sdNd943wSpeozmP1Ca90ZTGOnezl8/oJMg6fS8TzmWaJIzqCHF4I4UEooDsX8dCT+sN08IEy78jvTQjyD9/ZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714744080; c=relaxed/simple; bh=qJnuwtkeDuO1dEGZ+XpbtLgDbxS73SvTU0QT3E/p+rs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nt1/w6yzPTLY2rpQc8avF+c/kGZlcYCGvlQE5mHXoAH8zy6ll8KAeRYsN36lNabT11iOFEMl/kKvu3IM/jqYdE56/DYH+I/5XqzI39tDeY5ZgDqTEb6eqyV9g/jiPXj73hLo5Hac5OZID7lNP7dvOdLryDbcXKOwC/9xkERS+Mg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name; spf=pass smtp.mailfrom=shutemov.name; dkim=pass (2048-bit key) header.d=shutemov.name header.i=@shutemov.name header.b=moxrLXde; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=LZ9LVyuZ; arc=none smtp.client-ip=103.168.172.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shutemov.name Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.nyi.internal (Postfix) with ESMTP id 69076138030D; Fri, 3 May 2024 09:47:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Fri, 03 May 2024 09:47:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1714744077; x= 1714830477; bh=SLlrQkd2iXanI/kW9JruqRjjOcTmn5fEnvoJmg8IxSo=; b=m oxrLXde+RKZOxlvRz5sgWr7U5Xz/Ad5b8nMisWLAYXrFsuZZV0WUE4+Zt+pLrT7W CdnJ3DaQeIAU3OVN+0UdV8y0CtiYT+QjcfkcNbBpbBiRKso8aaGssrvDEKZ12mwB /NGjzhEZjW04+4MhCmXkXhmDL7bdrbYvKbsIDI9BSfCCVPi3fPELlIhuwTK8uhUS hVxhKADGsZIgwKZrs0jWAURPsG1+7adr9zHNdJGC2vXedx7dClKDostUM0QI+Vhf crrerf8p97cVjp306Ytj9c4RoBpUZ+rYls/KLYFxa9gkOqexbtdu8ihVbvlJYwDz uSt2awGcs2z+cZ0Q2XUlQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714744077; x=1714830477; bh=SLlrQkd2iXanI/kW9JruqRjjOcTm n5fEnvoJmg8IxSo=; b=LZ9LVyuZy3LNrPSCtehVDg0g4ltr0vsaceDJ/Zrf2VOP CBpySNhT7JNkZMM5jhnmy44rM1HReoQF05f1vOq/GshzwrA7pSYmVwuacyUAngka PAI113fYJTZrjiL/B5gGMT5wlSAWzzEmAMqCRo5dHMIOLPkAHnW2M+l48XSzAMqo b3v50aTIclbQjA2B4d9qBKQ2hVQ7tGf9YPmJRY+b92Rf4vhZSPbVlXVbTATzN3oL 7r5jT5mHRw2U/GdBtoqg2iP3tP2dMaNjMHdsUvrex5ExjywzdBGgQ2sSFZ8rm0un rs/SMEa7y9+paTsAuYRzejiHXswOqAvxNQNLPXV4uw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvtddgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpeffvdevueetudfhhfffveelhfetfeevveekleev jeduudevvdduvdelteduvefhkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 3 May 2024 09:47:53 -0400 (EDT) Date: Fri, 3 May 2024 16:47:49 +0300 From: "Kirill A. Shutemov" To: Ard Biesheuvel Cc: Chen Yu , linux-efi@vger.kernel.org, "Kirill A. Shutemov" , Vlastimil Babka , Nikolay Borisov , Chao Gao , linux-kernel@vger.kernel.org, "Hossain, Md Iqbal" Subject: Re: [PATCH v2] efi/unaccepted: touch soft lockup during memory accept Message-ID: <53exjhamp57x7brn2b5jxdpbzc3amv5i646gmgitnvwjgdwfrd@5v5qifom5tez> References: <20240411004907.649394-1-yu.c.chen@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, May 03, 2024 at 12:31:12PM +0200, Ard Biesheuvel wrote: > On Wed, 24 Apr 2024 at 19:12, Ard Biesheuvel wrote: > > > > On Mon, 22 Apr 2024 at 16:40, Chen Yu wrote: > > > > > > On 2024-04-11 at 08:49:07 +0800, Chen Yu wrote: > > > > Commit 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused > > > > by parallel memory acceptance") has released the spinlock so > > > > other CPUs can do memory acceptance in parallel and not > > > > triggers softlockup on other CPUs. > > > > > > > > However the softlock up was intermittent shown up if the memory > > > > of the TD guest is large, and the timeout of softlockup is set > > > > to 1 second. > > > > > > > > The symptom is: > > > > When the local irq is enabled at the end of accept_memory(), > > > > the softlockup detects that the watchdog on single CPU has > > > > not been fed for a while. That is to say, even other CPUs > > > > will not be blocked by spinlock, the current CPU might be > > > > stunk with local irq disabled for a while, which hurts not > > > > only nmi watchdog but also softlockup. > > > > > > > > Chao Gao pointed out that the memory accept could be time > > > > costly and there was similar report before. Thus to avoid > > > > any softlocup detection during this stage, give the > > > > softlockup a flag to skip the timeout check at the end of > > > > accept_memory(), by invoking touch_softlockup_watchdog(). > > > > > > > > Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance") > > > > Reported-by: "Hossain, Md Iqbal" > > > > Reviewed-by: Kirill A. Shutemov > > > > Signed-off-by: Chen Yu > > > > --- > > > > v1 -> v2: > > > > Refine the commit log and add fixes tag/reviewed-by tag from Kirill. > > > > > > Gently pinging about this patch. > > > > > > > Queued up in efi/urgent now, thanks. > > OK, I was about to send this patch to Linus (and I am still going to). > > However, I do wonder if sprinkling touch_softlockup_watchdog() left > and right is really the right solution here. > > Looking at the backtrace, this is a page fault originating in user > space. So why do we end up calling into the hypervisor to accept a > chunk of memory large enough to trigger the softlockup watchdog? Or is > the hypercall simply taking a disproportionate amount of time? Note that softlockup timeout was set to 1 second to trigger this. So this is exaggerated case. > And AIUI, touch_softlockup_watchdog() hides the fact that we are > hogging the CPU for way too long - is there any way we can at least > yield the CPU on this condition? Not really. There's no magic entity that handles accept. It is done by CPU. There's a feature in pipeline that makes page accept interruptable in TDX guest. It can help some cases. But if ended up in this codepath from non-preemptable context, it won't help. -- Kiryl Shutsemau / Kirill A. Shutemov