Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp571051rdh; Wed, 14 Feb 2024 05:38:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWdb6Qmt6B3heoZimOpUQzNIlJu+EUDIj7TYOg1Ty8DIoRDnN3dimRsSThUd4lMMXIYPsZxLdl54U0kSNmV437RQjuvUS6OnWcbQyix0g== X-Google-Smtp-Source: AGHT+IFfxIizxLbv9FmJKkPvahFlqdUBrm5l9OepYtpzLxBXdPqaoOBGTjmeJsiKw6w7ZcouuHuc X-Received: by 2002:a17:903:1209:b0:1d9:907f:636d with SMTP id l9-20020a170903120900b001d9907f636dmr3243114plh.10.1707917935822; Wed, 14 Feb 2024 05:38:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707917935; cv=pass; d=google.com; s=arc-20160816; b=w6d21JL3zMjYLfkaTh3HC1f0kNba8wd0DNApkm2+afcPxJivv5/AK1KElf/wrR/Zdj ZVQZZw+cDTnqvzpg/LEUiOE5ynjmOnOFQ7UWmeq5laMjX9OIDQ8sDJif8URobUqjXM9w zPm4GVFf5JXzGwbuHRlMlI7WR3ycx2ilfzJl0iPEWQHioPKr0Ui30WGTsoqNzq2P5aIV 1GFBMTrWeBo5OojIY6aJ7bBphaCQk1K/sgBwrAzWcAoXurGwWxVgmHVxnMm7m4HXvUeP GPdXg1JCBCIZ/IXhCX4YXBlBTCum/278G5vbu1BjMFHCJDt90IwHoci5p6oPZiuYjjrh v3ag== 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; bh=X5joV17jc9zxY3CFJKs5s/VTPNZHWkDyvqKld+pwzmw=; fh=ycJ9BbpfYsOoTEXE4OXPp6qrDv1kwD+Kv9054hRhHDI=; b=koRoEHzw2IoiVVMvX46SxO3B4LIoeaejn9FC/7EoLWUFmn1961aFWl3IamiCYF76yB VBoFRuv+0fgYro2OAsorVv56+mG1TATZdA2twbTnZyw2SOkwqZosnAKEqqCN89WlFVWa 8jys63yYk66PVUdnpTjOd7EB8T2D/bd4f7Vm3jScR3dkaTpsTjIsAEsgwitAVdXDuiKR mqSFxG3ToZ6IhG4pnO+WmnOXB8yupjIR4WipuCFdzR4SzJhhGjgaO7fIjurdtqTcsk9g oWmGxn9Kh2/jXQntMJWnScg7zMNg3dlpkjN2xoLs4+Qn3ljvknJO07vIlCVsFiW2IYKx gLMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-65277-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVMBNSf1q0mdmemzSuza2OHhjKxt88KVBP3wq4zA2ulf7M+kV4e4SRdYnjBg32EH//srqYVi81Vl1xMwLbukRJuRxNdQ2kG4CEJayQUQA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k11-20020a170902c40b00b001d8a94d10d9si3758599plk.448.2024.02.14.05.38.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:38:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65277-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-65277-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 98311B2454F for ; Wed, 14 Feb 2024 13:26:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EB4254729; Wed, 14 Feb 2024 13:25:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 819587499 for ; Wed, 14 Feb 2024 13:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707917151; cv=none; b=Z6EqRUfz3rDlswYB3TyebOqm5kig9xpnL+soKiSZLo3OU6tGE6H9NZo1KZAT0QY5hVeOh7KRnAQRdE5SmZQ0c2QAdjBAHSAUQG+4yHh3WOMZiYXQn4y8RfyZTrWSVR65bNx6538mCU57oVu8p7Lc4yuX6heZRA6k/y+Df2ezt80= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707917151; c=relaxed/simple; bh=hRdhPklLiRJFunCmr63f+3rRwn2AAXUVqCCfSHmiAcQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UFEQ/jp2++IIxJacxdgnVfyita6Klv7MK/1GB8xLf/WauLX5K8oTVAZeOhMy7ga25tujZvqm7tg2O68EnBHcOQbTk+pUvdTZle8axqIJAB9oruOMrircktjknr0vp4yrPvhYvbX81zO+xABHdvhtYN/831SjkXme+vuHF+ySIoE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C058F1FB; Wed, 14 Feb 2024 05:26:22 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.64.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 935313F5A1; Wed, 14 Feb 2024 05:25:36 -0800 (PST) Date: Wed, 14 Feb 2024 13:25:32 +0000 From: Mark Rutland To: Ankur Arora Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org, torvalds@linux-foundation.org, paulmck@kernel.org, akpm@linux-foundation.org, luto@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, willy@infradead.org, mgorman@suse.de, jpoimboe@kernel.org, jgross@suse.com, andrew.cooper3@citrix.com, bristot@kernel.org, mathieu.desnoyers@efficios.com, geert@linux-m68k.org, glaubitz@physik.fu-berlin.de, anton.ivanov@cambridgegreys.com, mattst88@gmail.com, krypton@ulrich-teichert.org, rostedt@goodmis.org, David.Laight@aculab.com, richard@nod.at, mjguzik@gmail.com, jon.grimm@amd.com, bharata@amd.com, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: Re: [PATCH 17/30] x86/thread_info: define TIF_NEED_RESCHED_LAZY Message-ID: References: <20240213055554.1802415-1-ankur.a.arora@oracle.com> <20240213055554.1802415-18-ankur.a.arora@oracle.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: <20240213055554.1802415-18-ankur.a.arora@oracle.com> Hi Ankur, On Mon, Feb 12, 2024 at 09:55:41PM -0800, Ankur Arora wrote: > Define TIF_NEED_RESCHED_LAZY which, with TIF_NEED_RESCHED provides the > scheduler with two kinds of rescheduling intent: TIF_NEED_RESCHED, > for the usual rescheduling at the next safe preemption point; > TIF_NEED_RESCHED_LAZY expressing an intent to reschedule at some > time in the future while allowing the current task to run to > completion. > > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Dave Hansen > Originally-by: Thomas Gleixner > Link: https://lore.kernel.org/lkml/87jzshhexi.ffs@tglx/ > Signed-off-by: Ankur Arora > --- > arch/x86/Kconfig | 1 + > arch/x86/include/asm/thread_info.h | 10 ++++++++-- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 5edec175b9bf..ab58558068a4 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -275,6 +275,7 @@ config X86 > select HAVE_STATIC_CALL > select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL > select HAVE_PREEMPT_DYNAMIC_CALL > + select HAVE_PREEMPT_AUTO > select HAVE_RSEQ > select HAVE_RUST if X86_64 > select HAVE_SYSCALL_TRACEPOINTS > diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h > index d63b02940747..88c1802185fc 100644 > --- a/arch/x86/include/asm/thread_info.h > +++ b/arch/x86/include/asm/thread_info.h > @@ -81,8 +81,11 @@ struct thread_info { > #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ > #define TIF_SIGPENDING 2 /* signal pending */ > #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ > -#define TIF_SINGLESTEP 4 /* reenable singlestep on user return*/ > -#define TIF_SSBD 5 /* Speculative store bypass disable */ > +#ifdef CONFIG_PREEMPT_AUTO > +#define TIF_NEED_RESCHED_LAZY 4 /* Lazy rescheduling */ > +#endif > +#define TIF_SINGLESTEP 5 /* reenable singlestep on user return*/ > +#define TIF_SSBD 6 /* Speculative store bypass disable */ It's a bit awkward/ugly to conditionally define the TIF_* bits in arch code, and we don't do that for other bits that are only used in some configurations (e.g. TIF_UPROBE). That's not just for aesthetics -- for example, on arm64 we try to keep the TIF_WORK_MASK bits contiguous, which is difficult if a bit in the middle doesn't exist in some configurations. Is it painful to organise the common code so that arch code can define TIF_NEED_RESCHED_LAZY regardless of whether CONFIG_PREEMPT_AUTO is selected? Mark. > #define TIF_SPEC_IB 9 /* Indirect branch speculation mitigation */ > #define TIF_SPEC_L1D_FLUSH 10 /* Flush L1D on mm switches (processes) */ > #define TIF_USER_RETURN_NOTIFY 11 /* notify kernel of userspace return */ > @@ -104,6 +107,9 @@ struct thread_info { > #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) > #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) > #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) > +#ifdef CONFIG_PREEMPT_AUTO > +#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY) > +#endif > #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) > #define _TIF_SSBD (1 << TIF_SSBD) > #define _TIF_SPEC_IB (1 << TIF_SPEC_IB) > -- > 2.31.1 >