Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5503355pxb; Wed, 26 Jan 2022 13:35:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjZNusTPUennNvHMpIPouqHaulwz72zf+uDXLCDDmsqiMiDbCbtrhOxHBasUFPOCSF4ciA X-Received: by 2002:a17:902:c702:: with SMTP id p2mr397155plp.140.1643232913780; Wed, 26 Jan 2022 13:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643232913; cv=none; d=google.com; s=arc-20160816; b=TWoNbVp4V/uaAceoDqv99OBwT7DLQSTVi8wiMfGad6WbRiat7LPlxATORa7Rb6OCqm ZlMUKXf4+nhuVo+pAWALknukOVV9Q7IR0Per3YnKJ7ljB+XNnvrlLpP7f+WQJ47gG7Tr mVAPmmd+c6PdkIRkAC9ewO95EdLPpz94r5otiEg0z/TTXoX7rI27EEYV3AOvrLzKd+6a kokwlEzrYg3KnUA6UAJLGNnOgC9OIM1Qppdx7a7F3VXIOdEQGbUEak6NjFR36AxKfl/1 hLXiNFRBxULnwiDfsk0at6L1zWZDpv4HQ5/ra49hdfVmVNO3WF5+a4kosr+incTH7voJ 6rDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Vvwwwi2y8sk0OUKGftZ+OHGkB4pRpeCyrcUutZQZd8g=; b=HHvD8OKiUz+oBT9hVAFUU10LOiC78hF51QxiZZf+ynZxhzEPraVZ/Jtg2n9jzFhSv5 yy1aBPa0BcQPAS1wlTRyJxt/vquC510vYuSk2w/W6J72E6WDX22mZ/ZTJGw1DVw0dZQW RCyiRAy7989NAGLTMOALe/f2OaaRfvPhDR4oaImBQaglQGqRSJUEDKhULx+0DKWHF9ap v8LNBENqnvNkEKhTfni4KsMYdsauepLkN83P/G6L0Hk+7Oo7W77tCt1UCZkR7IuZZ05X 5/Cw0GgvijI8pE/queJqL7T/JjHY5eN7h78Ve12kZPOapMNwuesv7jx+yaOBA+pMJ16g 0y3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rBnUdQew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kk2si4454898pjb.66.2022.01.26.13.35.01; Wed, 26 Jan 2022 13:35:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rBnUdQew; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242175AbiAZOcv (ORCPT + 99 others); Wed, 26 Jan 2022 09:32:51 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:52546 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242194AbiAZOcs (ORCPT ); Wed, 26 Jan 2022 09:32:48 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A4248B81CEB; Wed, 26 Jan 2022 14:32:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE455C340E3; Wed, 26 Jan 2022 14:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643207565; bh=gKf9zur6l6kv4MdYfaOpKzS4yNvRurcGXURYpzrdMG0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rBnUdQew3vXEXa9GuzBKy2mEi4MS7roxhvTzx/LreGnArMj2bvcSrO3/UDWV91nmK zD7Gz+ooqVokYVDxcWuF63eh3BbIKBIj1td211gAC/P2ej+FOTmuzDmgG1eGI4IhJf XDWZh88RH+3CdSgmCHtVodUNTZcDe6M+0lBFgQSFpKzSuXamoS1tQxcYdPhq+jtX9p ayuldAQic/PPXsWHyDnfd7izDSU5Nrl5WkvMgYppZXRhHWmSxWGA4h1jgEp5yRkEsH PY0cirScc9E3e3/99myFmM+77jaVB7BJ0JpEkuM2S2yuZ0WGlx0xMeuuzaES1MJOyz Dvsc/EXAj0xCg== Date: Wed, 26 Jan 2022 16:32:24 +0200 From: Jarkko Sakkinen To: Reinette Chatre Cc: dave.hansen@linux.intel.com, tglx@linutronix.de, bp@alien8.de, luto@kernel.org, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org, vijay.dhanraj@intel.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH V2] x86/sgx: Silence softlockup detection when releasing large enclaves Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 10:22:43AM -0800, Reinette Chatre wrote: > Vijay reported that the "unclobbered_vdso_oversubscribed" selftest > triggers the softlockup detector. > > Actual SGX systems have 128GB of enclave memory or more. The > "unclobbered_vdso_oversubscribed" selftest creates one enclave which > consumes all of the enclave memory on the system. Tearing down such a > large enclave takes around a minute, most of it in the loop where > the EREMOVE instruction is applied to each individual 4k enclave page. > > Spending one minute in a loop triggers the softlockup detector. > > Add a cond_resched() to give other tasks a chance to run and placate > the softlockup detector. > > Cc: stable@vger.kernel.org > Fixes: 1728ab54b4be ("x86/sgx: Add a page reclaimer") > Reported-by: Vijay Dhanraj > Acked-by: Dave Hansen > Signed-off-by: Reinette Chatre > --- > Softlockup message: > > watchdog: BUG: soft lockup - CPU#7 stuck for 22s! [test_sgx:11502] > Kernel panic - not syncing: softlockup: hung tasks > > sgx_encl_release+0x86/0x1c0 > sgx_release+0x11c/0x130 > __fput+0xb0/0x280 > ____fput+0xe/0x10 > task_work_run+0x6c/0xc0 > exit_to_user_mode_prepare+0x1eb/0x1f0 > syscall_exit_to_user_mode+0x1d/0x50 > do_syscall_64+0x46/0xb0 > entry_SYSCALL_64_after_hwframe+0x44/0xae > > Changes since V1: > - V1: https://lore.kernel.org/lkml/1aa037705e5aa209d8b7a075873c6b4190327436.1642530802.git.reinette.chatre@intel.com/ > - Add comment provided by Jarkko. > > arch/x86/kernel/cpu/sgx/encl.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c > index 001808e3901c..48afe96ae0f0 100644 > --- a/arch/x86/kernel/cpu/sgx/encl.c > +++ b/arch/x86/kernel/cpu/sgx/encl.c > @@ -410,6 +410,8 @@ void sgx_encl_release(struct kref *ref) > } > > kfree(entry); > + /* Invoke scheduler to prevent soft lockups. */ > + cond_resched(); > } > > xa_destroy(&encl->page_array); > -- > 2.25.1 > Reviewed-by: Jarkko Sakkinen Tested-by: Jarkko Sakkinen (kselftest as sanity check) BR, Jarkko