Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp68813lqb; Tue, 28 May 2024 09:03:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXuGihY3wIoiICKzVkIUjhODRgjgFrOnGvk/dhRztdqAcC166JD5nwQ/iC2VH/5pEZRD//tvHATrEsMfJaib+tvwBMKJWAkqMYLENv5Q== X-Google-Smtp-Source: AGHT+IEr9D2KvpNFKCAMXSqMS2zfOo3lr2pxVRF/i+iJREzUXXrG42Ghc5nnU5ogQrJnevrbVoBh X-Received: by 2002:a05:6214:1931:b0:6ad:5d19:d9cd with SMTP id 6a1803df08f44-6ad5d19dd12mr93705886d6.37.1716912222234; Tue, 28 May 2024 09:03:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716912222; cv=pass; d=google.com; s=arc-20160816; b=xUDVrlrCQCfArFdSUauQYweueYH5+mlMu1fgB3meXSSAtAJPfuQx5aV/Ibg32PelfX k1A+QRuZ39ai68ZwoAdNOyS8D2Lu0FYwuBAtwtzYwiMazY/yis9lJ5z6WJBBBMCMFT9S 2NyRZn3Jo37Tr+dZ562CRL5T4zUPV4B7Z3kv+aBU+7wJhF9EcEAE697m8Xpd4MBkTnzs A+6QvP20Pdj7bfRhURoTSatVVUwCWGfs8CYa+wgqyBy4z0AgphGlwVDaPiWBflxplhg+ ccNscJ4jizTd2BL8CgwkKyFQwT7lsdy/hgujQiu3th7q7lZWIQzRD4K6x/nCq9sxvhhL w/Yw== 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:dkim-signature; bh=T6m7GRL/l5fVnq/ReBptkLC/Ipu0179TKWXFXUccS2w=; fh=hY17OQvXoJ9DHlEEMY8v/C6Ng54kuJ59VnsDW0bVbzs=; b=PkMFFxG+gfxcHNR41VJnz7QzExbSqyCYaQTMWxXrmY7loqHmAf7cJR1JFtFvBbpGBN 52/z8nTqI2dBwZlHPcODhUE9xAWm0SJeyEXt+dnPzXBUz7A2fMAMS5qoaSh4Qa5fiws1 wvMZjRqeE/ouZuY992cuKnNr0Czu0EayneFt9ZCVABkOCpSO9V+ZpM6DlMiz9tzw06kO LmLWYWLcE6TeVZfJodGCoVaxTog8qobS4odOGcUe8JKwiKhgsBmOC7eFKrnNQTo4I3OX h1mqOfJ4TKDKCUfrBRAID4BMipV1oN2HD3Z9NEi0Ro1qUwSWZ2rgKKGMH7Dp9gnGy/dq qhlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=AtVhYV2B; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-192715-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192715-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 6a1803df08f44-6ac117057ccsi108645386d6.341.2024.05.28.09.03.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 09:03:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192715-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=@infradead.org header.s=casper.20170209 header.b=AtVhYV2B; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-192715-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192715-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 E051E1C2271D for ; Tue, 28 May 2024 16:03:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 700F2171E60; Tue, 28 May 2024 16:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AtVhYV2B" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 39EAC170834 for ; Tue, 28 May 2024 16:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716912206; cv=none; b=U0uGdqbj6dFljocT9U+VuLoMKckyL6hIPol+3zq4IQZkS0BZDvR1ehuPrrQKCH6H3BlKfQ8RRF1K21sDfRGelL0whPTb2QNPrEujh5dZCjjNKxmMnebayx6BEaixOD343Q/hpWWfaj2USoRHS+uLowSGUQk4yr/kssIRqTjM+EQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716912206; c=relaxed/simple; bh=Hc62IPRKaTz8big8EcySqThUgK13WcPmdZcRYBCx46E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UTwUEXP4MGYuOYQmF/A4vvDTADLcrecOmJdATVEuA1J1hpg5T/642l6YFL3RkRYPtVxI6EYn28OM5XZdQbNIS0DeNVwmBhLi+3cQBXQTWr8otS9RqguvynUwm0pNI4pcpaK8GFHxHG3oTI4DN5n8LQCBEntIiawjFQYaFv3C0S4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=AtVhYV2B; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=T6m7GRL/l5fVnq/ReBptkLC/Ipu0179TKWXFXUccS2w=; b=AtVhYV2BMBwMSrezNMKiKQKLzN PAxqNnyWDZAmyp8kiu0yKQ9vSUizDlmBmtMj5qKgERpqZGrJsiDW7W3uGG5NXVNfXP7K8fLoCyuzJ +b4UM3BpgdQ2zw/jPfIJs0+xmUR2XUHnIlyqv7aP2xWY9niPl95zOAjXiN8TOLvt4ChrlnK+wvc3V pTYT8sPCmn1sLFJ6aaSNyytASGINL6wOxLEMC5rNUUv7Qi9kOyKCzGc5Je4l8GWE3XWheTmUSj9go 9y++geS9iCmp03+aMRgxSQFl3/k7DDy4dMg/N04BuMIbe498Pz7wDy+ZA5gV4YWN3qlDGNMTrwxrh 9UCCiOXg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBzI7-00000008nma-1b4y; Tue, 28 May 2024 16:03:11 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 0729030058E; Tue, 28 May 2024 18:03:11 +0200 (CEST) Date: Tue, 28 May 2024 18:03:10 +0200 From: Peter Zijlstra To: Ankur Arora Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, paulmck@kernel.org, rostedt@goodmis.org, mark.rutland@arm.com, juri.lelli@redhat.com, joel@joelfernandes.org, raghavendra.kt@amd.com, sshegde@linux.ibm.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, Arnd Bergmann , Ingo Molnar , Vincent Guittot Subject: Re: [PATCH v2 06/35] thread_info: define __tif_need_resched(resched_t) Message-ID: <20240528160310.GB26599@noisy.programming.kicks-ass.net> References: <20240528003521.979836-1-ankur.a.arora@oracle.com> <20240528003521.979836-7-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: <20240528003521.979836-7-ankur.a.arora@oracle.com> On Mon, May 27, 2024 at 05:34:52PM -0700, Ankur Arora wrote: > diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h > index 65e5beedc915..e246b01553a5 100644 > --- a/include/linux/thread_info.h > +++ b/include/linux/thread_info.h > @@ -216,22 +216,44 @@ static __always_inline unsigned long read_ti_thread_flags(struct thread_info *ti > > #ifdef _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H > > -static __always_inline bool tif_need_resched(void) > +static __always_inline bool __tif_need_resched_bitop(int nr_flag) > { > - return arch_test_bit(TIF_NEED_RESCHED, > - (unsigned long *)(¤t_thread_info()->flags)); > + return arch_test_bit(nr_flag, > + (unsigned long *)(¤t_thread_info()->flags)); > } > > #else > > -static __always_inline bool tif_need_resched(void) > +static __always_inline bool __tif_need_resched_bitop(int nr_flag) > { > - return test_bit(TIF_NEED_RESCHED, > - (unsigned long *)(¤t_thread_info()->flags)); > + return test_bit(nr_flag, > + (unsigned long *)(¤t_thread_info()->flags)); > } :se cino=(0:0 That is, you're wrecking the indentation here. > > #endif /* _ASM_GENERIC_BITOPS_INSTRUMENTED_NON_ATOMIC_H */ > > +static __always_inline bool __tif_need_resched(resched_t rs) > +{ > + /* > + * With !PREEMPT_AUTO, this check is only meaningful if we > + * are checking if tif_resched(RESCHED_NOW) is set. > + */ > + if (IS_ENABLED(CONFIG_PREEMPT_AUTO) || rs == RESCHED_NOW) > + return __tif_need_resched_bitop(tif_resched(rs)); > + else > + return false; > +} if (!IS_ENABLED(CONFIG_PREEMPT_AUTO) && rs == RESCHED_LAZY) return false; return __tif_need_resched_bitop(tif_resched(rs)); > + > +static __always_inline bool tif_need_resched(void) > +{ > + return __tif_need_resched(RESCHED_NOW); > +} > + > +static __always_inline bool tif_need_resched_lazy(void) > +{ > + return __tif_need_resched(RESCHED_LAZY); > +} > + > #ifndef CONFIG_HAVE_ARCH_WITHIN_STACK_FRAMES > static inline int arch_within_stack_frames(const void * const stack, > const void * const stackend, > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 233d1af39fff..ed229527be05 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -2511,7 +2511,7 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status) > if (softirq_count() >> (SOFTIRQ_SHIFT + 1)) > trace_flags |= TRACE_FLAG_BH_OFF; > > - if (tif_need_resched()) > + if (__tif_need_resched(RESCHED_NOW)) > trace_flags |= TRACE_FLAG_NEED_RESCHED; Per the above this is a NO-OP.