Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp544813lqb; Wed, 29 May 2024 03:50:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZHGq3VJyigJKx3/gVgwowZdjzwrESesBz3pIm/YR4UR2EThF+Czsv/QP3SZIIDeSipatRXi+Qr5CStqoQSTXc+cpW131wSwHtIgPWtA== X-Google-Smtp-Source: AGHT+IHAHFpsCnZVlIQwqFnYjKR02kn2DpZoWSaPNbARlH3CuXB7mTFKcq/8JuqP2DWeDDvYkIhp X-Received: by 2002:a17:902:f683:b0:1f4:ae15:f1c7 with SMTP id d9443c01a7336-1f4ae16038dmr65275395ad.17.1716979858830; Wed, 29 May 2024 03:50:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716979858; cv=pass; d=google.com; s=arc-20160816; b=l6hryAt6ZxXg8MQdi23TyKf6kVPhJVDPla7NvSvO7pasL2pr/lzXyCizek+ZBWGfmN Szw//onEgt+Q93R1IvKZJPcfTwkOkBr8NVA8PjzYguzq6P1AbNRc8UBYrNJK959TsOGL hMVWsItRv2nURO/eTpmTplurwuCu3qsZK0JiKIGBPaZojIGC6IlZ7zlJgbpic9kVGfl5 ZefHLPtV+uachi/6HEwajKKydm9vQdnZ9bPSAd7QuqAcjUr88DrWDFpxP9nrF+lUuTNv ouGsUqKE4ANkVmXex7qMgdCCasOUrGXA8mxqLSO8N6X08FI6SSmZY7pS8iJ7g3CXxVvT NS0A== 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=/gJb3HA1e2GgiV5CyomcmHGNAjwVDxaf7X6WiAqGPqA=; fh=E6nMY2SCCK07HbGulrZp7JUfPuXw9pDP0AaUuxDtGK0=; b=jHYOxRc+LIY2qoqC8d3NbEs1Ogm/Y8SjXIXb42qCG9+ffF8Tt3PVL0M6iZqrDv9fju Xi5GCbndBjD+coBTnmkBjefcY0Et2bi9VadFZOwz8s9fzSFvG10Cm6ots7qvfcKsZghJ spmwtrSVzalhoyI2douMT/U/12fbgQ7nvAKJ4+2EL07aD37yA0O7AX5kAf+cwBGziWC6 WNbCZNu0dO7hHEBBEU0b3yn/gfDAl5iD6/RSJMk3pZoxMDD5peACf5gHK8RBhwoWPKlc s9U4umlQ3nZONqB4Upk91v/O0dd9nlfdCrEKckim7C8KdSb4Z4yYKIhhyH/Cob/RrDX8 yPew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=CXCd440G; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-193849-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193849-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c970f1bsi97048335ad.280.2024.05.29.03.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 03:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193849-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=CXCd440G; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-193849-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193849-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 53F2E286FD8 for ; Wed, 29 May 2024 09:32:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 758BB169396; Wed, 29 May 2024 09:32:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="CXCd440G" 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 DA1A0175B1 for ; Wed, 29 May 2024 09:32:21 +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=1716975143; cv=none; b=GbQyVxa/z0KhOljHl2aC4WpzPIeZ3aq7wj/EeaoFEe8YRVHXuWmOKsFvkEN3fIcdPJnz+uwZe52DVTj+d9gDwajsY7Ul2MF/3phfv8sWFKIWQBW/XY0GGlsP5g/IQabXR+8vnSgUpAj7CQHLAYSIyXaoRLNaDuQHHlJT4gWv/cE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716975143; c=relaxed/simple; bh=EWAPZgeL3+uGu8UqpwB3Q+nWlC0SjXpgLPpxeANvK5w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EULACt7GRcGrUXtH6TGcWXzeXEV35nALnLs2SJMTrGc6thMbltwKWH9Z4YTkI8wuwXZaWAyAKZZVRz482Jy9H4Za6Qg4LsO3JavKRj9pNRp0jVK8IxEjh74qbJIox5Pna9ucl6triwT/QlceMrBe4DFKBEv1dKuR4PCZlu4z7CI= 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=CXCd440G; 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=/gJb3HA1e2GgiV5CyomcmHGNAjwVDxaf7X6WiAqGPqA=; b=CXCd440Gy7nH0JmVHLFiesU09E 0rx+Im+5GNTK58jHI/wLeJUMHCyA5B+cOFlXXgTsxvzt7TTEHtDnhUSN4A46nyxeq31JymsP3yeV8 Zaqpj/JdjhJn0uJUq0MOlujRsrvw5c0n9GjmTld0Mx/dADwpFz43j4+0hxJ6XANRguzi7n1X2BGJC fWw6WMrL6Nh3NvaZI2iJ4hUbaaiGtDAv24vPw2Gr8HGArgeM12o8V9cNUrrJ1Ji7VeEsNivIir+m3 +NrJfrVblorPnqGJkC9pmGdErC09WxJdfUplJGJUCMFdirlGaEg1gCjbQO5Wz0vXfQbpss4T3duUd neiTTp1Q==; 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 1sCFfC-0000000DWvX-35jf; Wed, 29 May 2024 09:32:07 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id A43EE30073F; Wed, 29 May 2024 11:32:03 +0200 (CEST) Date: Wed, 29 May 2024 11:32:03 +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 21/35] sched: prepare for lazy rescheduling in resched_curr() Message-ID: <20240529093203.GK26599@noisy.programming.kicks-ass.net> References: <20240528003521.979836-1-ankur.a.arora@oracle.com> <20240528003521.979836-22-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-22-ankur.a.arora@oracle.com> On Mon, May 27, 2024 at 05:35:07PM -0700, Ankur Arora wrote: > @@ -1041,25 +1041,34 @@ void wake_up_q(struct wake_q_head *head) > void resched_curr(struct rq *rq) > { > struct task_struct *curr = rq->curr; > + resched_t rs = RESCHED_NOW; > int cpu; > > lockdep_assert_rq_held(rq); > > - if (__test_tsk_need_resched(curr, RESCHED_NOW)) > + /* > + * TIF_NEED_RESCHED is the higher priority bit, so if it is already > + * set, nothing more to be done. > + */ > + if (__test_tsk_need_resched(curr, RESCHED_NOW) || > + (rs == RESCHED_LAZY && __test_tsk_need_resched(curr, RESCHED_LAZY))) > return; > > cpu = cpu_of(rq); > > if (cpu == smp_processor_id()) { > - __set_tsk_need_resched(curr, RESCHED_NOW); > - set_preempt_need_resched(); > + __set_tsk_need_resched(curr, rs); > + if (rs == RESCHED_NOW) > + set_preempt_need_resched(); > return; > } > > - if (set_nr_and_not_polling(curr)) > - smp_send_reschedule(cpu); > - else > + if (set_nr_and_not_polling(curr, rs)) { > + if (rs == RESCHED_NOW) > + smp_send_reschedule(cpu); I'm thinking this wants at least something like: WARN_ON_ONCE(rs == RESCHED_LAZY && is_idle_task(curr)); > + } else { > trace_sched_wake_idle_without_ipi(cpu); > + } > } > > void resched_cpu(int cpu)