Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp488541lqb; Wed, 29 May 2024 01:28:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/+11DJb11S9JpmW7PaR5t/gcbFgEWtYYlPbwH0uz9adiwAMNlG7D0WBLfBmNYvGwVWmi+gIcfs7bjIN1fI4EuqSzL7H+tAMk1P6ogdg== X-Google-Smtp-Source: AGHT+IG6k6ZnzKXkE5grqjWJjkQ4WKRy/TJpp7v5MKDStFAM1h9M0G3Gz56E1zSDG+bcnllTxiFy X-Received: by 2002:a17:902:e546:b0:1f4:8a14:f4c9 with SMTP id d9443c01a7336-1f48a14f9cbmr104413405ad.69.1716971331167; Wed, 29 May 2024 01:28:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716971331; cv=pass; d=google.com; s=arc-20160816; b=jQMlj1E11raRt08XJruW2VqFAOSa7mUrA6/RGcQwEYwbfHm1Kmw4k4Pl2LGUe0WXUS Shp4z0pKYMmGnxWhfTFaQVspTx7deiiFP7UcjLRWYGmDxWXfjvfb2dsTyBS8mNw1LaQL YVsIJoVnYV7e3w5lJC4DrdBXiYyfM9VQSFtbDBl2Jduv+t2OA3xmtQe3XPVtbtOwgFmC MGGQVvrzTm2F0Ad3HTYq/iowgqpHk6tKiVbSqBXyFl4dcXr3XoWyQrmhjUN9VlVYFyLp 5ggP3b1xQMfOSgsh56hryhX3MJn9i1Y4AwxruQQIYYPpYiHpF23IcJQ/t4ZVi6bM9lex C7jw== 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=KedQfEOQGeFOWrHJKw+wmkld2KwmplKUWUwSLw2frR0=; fh=E6nMY2SCCK07HbGulrZp7JUfPuXw9pDP0AaUuxDtGK0=; b=fXAybJnyKjs75FH9wbIgHqKZMcITNDni/1s3MuHecixHso1dXBqyTrFYgPrNZGWS/t GB00KFcMW5HtcuKo15cPlTctGpvTfGwvTXbNIbKaQNvVGJo9bBYQpLX2TgYUsG8F8VTg IGcnxIzkGcd/+sT6vPH+VNlDl8lh9LY4gETrEgNewjOnsq1yMk1WgA7DcT664Xsigvlz 1V/oOXFVTnCoTvK2op7wg2DqLaKR1OLPmXEn7DAQZaswu3lo3mUc0uJzZaogGGELQxIT yT1mfVuV7BoNUCBx2twwIp4juxDq/aKxzhisUzt6x8BUfQFtHJu3HlQ7f6Xdahmpiwjr chTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=QkRXAPMF; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-193733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193733-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c7c376csi97215305ad.149.2024.05.29.01.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 01:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=QkRXAPMF; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-193733-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193733-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CBBEE294D48 for ; Wed, 29 May 2024 08:28:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63B04168C1A; Wed, 29 May 2024 08:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QkRXAPMF" Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D6B7F33CFC for ; Wed, 29 May 2024 08:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716971144; cv=none; b=T/nnwUSc5EI4Tnpk9N1a33rQzdaMAzaVYGwIJbBhTazviaeWOhuAj+S+lZaJwBJoofAFYtxeKeuCpIzPQH8YamudZ59jZ9SS5EpBKNMTQ1TkQRUYIlklo/PkRoEruwPVdWSuwhW3i9GFdeVnE6I9VIX+yi35JT24t6NE407bioo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716971144; c=relaxed/simple; bh=Z56n3pknVfrdXrYQxZGakMySYcLNvBhOCiTixUpe2BA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CUEBy/BG/JvPWNjc+j0RRky3JJd6VmYd088Psl82GXHizKKdNJ0Zrl5weJhp+0AkV1GtNwp5fKw1+qoYmSWGphKNPkSNdTg/WEBmkJvctFK4t8noVWGHKSInaMtkpCGEjjBh82KFEUn2Tw0gChDbHkNGVYLD5/n/gEp+DOV+kIY= 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=QkRXAPMF; arc=none smtp.client-ip=90.155.92.199 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=desiato.20200630; 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=KedQfEOQGeFOWrHJKw+wmkld2KwmplKUWUwSLw2frR0=; b=QkRXAPMFWCH8tpmeWVx5ll+tyl Y7tOijGOQF2hr5zB0I4JweymOLwa2cTwa93rixzwb73HGFf6ZnX/rZ0uQyaiZmhvNobGE2HWkKfrH Zw8uCOT91n9lnOPmZDNZLm4VCS/RL8h9q694IxKviy0OaUyKTai8m0K8yvUhlPT6BMC3E7utmPatr BxBZYbME8/yQ+fV/BymLX16fFuGsbrtuCp2LMffeirC+p+Men7pYAHgb8JSnr+F89YEnXzPhJVEWE wWkud4Fau1Ud4kQz/SSN/c2W395KONMY7LAcnNP7U0EJdHb9iXc3y1XAVwWy1dtj01kZ8qh+lFJq3 XBS1G5ow==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCEcm-0000000DT4e-3wsZ; Wed, 29 May 2024 08:25:33 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 238E930073F; Wed, 29 May 2024 10:25:30 +0200 (CEST) Date: Wed, 29 May 2024 10:25:30 +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, Ingo Molnar , Vincent Guittot Subject: Re: [PATCH v2 07/35] sched: define *_tsk_need_resched_lazy() helpers Message-ID: <20240529082530.GJ26599@noisy.programming.kicks-ass.net> References: <20240528003521.979836-1-ankur.a.arora@oracle.com> <20240528003521.979836-8-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-8-ankur.a.arora@oracle.com> On Mon, May 27, 2024 at 05:34:53PM -0700, Ankur Arora wrote: > static inline void clear_tsk_need_resched(struct task_struct *tsk) > { > - clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED); > + clear_tsk_thread_flag(tsk, tif_resched(RESCHED_NOW)); > + > + if (IS_ENABLED(CONFIG_PREEMPT_AUTO)) > + clear_tsk_thread_flag(tsk, tif_resched(RESCHED_LAZY)); > +} (using tif_resched() here is really uncalled for) So this will generate rather sub-optimal code, namely 2 atomics that really should be one. Ideally we'd write this something like: unsigned long mask = _TIF_NEED_RESCHED; if (IS_ENABLED(CONFIG_PREEMPT_AUTO)) mask |= _TIF_NEED_RESCHED_LAZY; atomic_long_andnot(mask, (atomic_long_t *)task_thread_info(tsk)->flags); Which will clear both bits with a single atomic.