Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2382813rdb; Thu, 21 Sep 2023 17:59:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeIjJ48o+vJ5JwyNRyTycfpjMUhU+U8i/dsl/FRGh7D4yZUhBOBVqe1xcQAZG4jx1ygFSB X-Received: by 2002:a05:620a:454b:b0:76f:27af:2796 with SMTP id u11-20020a05620a454b00b0076f27af2796mr8672825qkp.60.1695344390958; Thu, 21 Sep 2023 17:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695344390; cv=none; d=google.com; s=arc-20160816; b=o08/R8KFPkSTJ94ryFt0eTPrt8rYDqawsD/ECp+xs24UPhtMBIXmjyaTQ2mcRdvoQZ k4u0JGt1y9y9Re3TTesKPSFAl1n69+3clJ7/NzNFI/f9Q1abCv5LSQaxJtnpLVbhqNgG jvGTnY9uOaHxOb1ENN17FLFyJR9G2XcBvooCiTSf2247HcZm4ZJI5Px5PcvxQuOFkZ/8 z+cCE77wgUQgvF2RsYkbFfpVbAtBwRx0vC7W+d5VjMHNlm6Yt4fYsQREESmrXXhZLaVR tICupUap4XVgbHHbc8OKT4NNk3RaHAADwVkyQoFWSTGfHJZ4/JIJcBxc2TvugUNQFOqV M+Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=19SW2gsLL1UdhsDBKiLlNxKkdUUQxSgCx6gW88i2Zes=; fh=7oA3gBD8Jke0vU/jYLQfEEiFsHKW+fQAOkKaPD9iYmk=; b=EkbVgC+gQgCzzYZswnHS+YerkJQB9vWLTHV2t9dfXY5jNmEy9tvdGojQqbMTk3HPep 2y6dbUj5GQMtgP/1YG9qK3siuiUjEZbQVPVCVI4poDaKrzsxy7qJVOHYSyV6TRuI2A3X 7FGB6blu4OmPzB/yKwS1gQ2AR04liTUfyb9/jOL5Wg8rle24ST5sY0lr9JKmHTKHALm4 WXzZPbdidqog+/xSxhc+DVnHLAMIEbWsBXusXc8ACEMhg7iGphL+ZSpL/2CsNBqgtBrW +kFvWA9+TvGfjZhbGgPAagPR7TeSV1OAAx1olZcc3YpcxZ836Av6MN3eIUzG79uhjt2p +bbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NC9YxZCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id cf4-20020a056a02084400b00577ed0133d2si2576945pgb.453.2023.09.21.17.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 17:59:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NC9YxZCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5D86480947ED; Thu, 21 Sep 2023 13:07:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231484AbjIUUH5 (ORCPT + 99 others); Thu, 21 Sep 2023 16:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231506AbjIUUHq (ORCPT ); Thu, 21 Sep 2023 16:07:46 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0329D1FE8 for ; Thu, 21 Sep 2023 10:02:15 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-99c1c66876aso145071666b.2 for ; Thu, 21 Sep 2023 10:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1695315662; x=1695920462; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=19SW2gsLL1UdhsDBKiLlNxKkdUUQxSgCx6gW88i2Zes=; b=NC9YxZCcV5mWuV4hivgJTEtsoQObB4P+6CvY2dBTY7it/cPw2l1uj4YlsZGjWUdlHW CENcSL3V6EPyb5lelGqVJ1Lsb0GIdRG0u14GUJ0b/ICutLNM03RdA/ZSz/f9HYmm3sCt fvfVjkuuT576uOfnkyVrIWTzESnr/40Br0NcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695315662; x=1695920462; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=19SW2gsLL1UdhsDBKiLlNxKkdUUQxSgCx6gW88i2Zes=; b=Rg2vBxCqPeTwh/wgYkqqFa1Qi/EU5A0rhcGcIZAviFO67DztjPLbLi9S5J0Tu6U6Oo IEGu1nDeq8A7/LYhNeFhUez//k7WZKRdSHyxhZ8riAvKlTM4us9Je6QNARMVYKsg4a1C 7/dGVCbA+eDevHKqmovZZEpK+usQZl3NjDAdKqOG9pAapNCPXp/DldQJqhjs/15m9aIn DU6xXIs8IcB1ZKmxv1+EZJR6wAjXaEyVmi4pmyYmLfJ0sy6jw3JbvCvauO4otxR6yWU9 4FYb4aHUyoxY38Dh0Kxy+tm9xQp+04AAoNDdMPcvOCDAoPZDhI/pF7eZiGh57MyxgB/z EDWQ== X-Gm-Message-State: AOJu0YwKNU2GPsZ2HOeB8oSH4Q2upC5vFba4DnpmZiaI1gnzwsf5i4SH zkrUCT1LT54CrSuJRjAHlv/fr77U1vxWF8N8WcNnDZU4 X-Received: by 2002:a17:906:2cc:b0:9a5:b878:7336 with SMTP id 12-20020a17090602cc00b009a5b8787336mr5997744ejk.7.1695312073186; Thu, 21 Sep 2023 09:01:13 -0700 (PDT) Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com. [209.85.208.53]) by smtp.gmail.com with ESMTPSA id l3-20020a170906230300b009932337747esm1263922eja.86.2023.09.21.09.01.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Sep 2023 09:01:12 -0700 (PDT) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5310a63cf7bso1362565a12.1 for ; Thu, 21 Sep 2023 09:01:12 -0700 (PDT) X-Received: by 2002:aa7:c448:0:b0:52a:6497:d02b with SMTP id n8-20020aa7c448000000b0052a6497d02bmr5458698edr.16.1695312071878; Thu, 21 Sep 2023 09:01:11 -0700 (PDT) MIME-Version: 1.0 References: <20230830184958.2333078-8-ankur.a.arora@oracle.com> <20230908070258.GA19320@noisy.programming.kicks-ass.net> <87zg1v3xxh.fsf@oracle.com> <87edj64rj1.fsf@oracle.com> <87zg1u1h5t.fsf@oracle.com> <20230911150410.GC9098@noisy.programming.kicks-ass.net> <87h6o01w1a.fsf@oracle.com> <20230912082606.GB35261@noisy.programming.kicks-ass.net> <87cyyfxd4k.ffs@tglx> <87led2wdj0.ffs@tglx> <8734z8v1lo.ffs@tglx> In-Reply-To: <8734z8v1lo.ffs@tglx> From: Linus Torvalds Date: Thu, 21 Sep 2023 09:00:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 7/9] sched: define TIF_ALLOW_RESCHED To: Thomas Gleixner Cc: Peter Zijlstra , Ankur Arora , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@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, rostedt@goodmis.org, jon.grimm@amd.com, bharata@amd.com, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, jgross@suse.com, andrew.cooper3@citrix.com, Frederic Weisbecker Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:07:57 -0700 (PDT) Ok, I like this. That said, this part of it: On Wed, 20 Sept 2023 at 16:58, Thomas Gleixner wrote: > > -void resched_curr(struct rq *rq) > +static void __resched_curr(struct rq *rq, int nr_bit) > [...] > - set_tsk_need_resched(curr); > - set_preempt_need_resched(); > + set_tsk_thread_flag(curr, nr_bit); > + if (nr_bit == TIF_NEED_RESCHED) > + set_preempt_need_resched(); feels really hacky. I think that instead of passing a random TIF bit around, it should just pass a "lazy or not" value around. Then you make the TIF bit be some easily computable thing (eg something like #define TIF_RESCHED(lazy) (TIF_NEED_RESCHED + (lazy)) or whatever), and write the above conditional as if (!lazy) set_preempt_need_resched(); so that it all *does* the same thing, but the code makes it clear about what the logic is. Because honestly, without having been part of this thread, I would look at that if (nr_bit == TIF_NEED_RESCHED) set_preempt_need_resched(); and I'd be completely lost. It doesn't make conceptual sense, I feel. So I'd really like the source code to be more directly expressing the *intent* of the code, not be so centered around the implementation detail. Put another way: I think we can make the compiler turn the intent into the implementation, and I'd rather *not* have us humans have to infer the intent from the implementation. That said - I think as a proof of concept and "look, with this we get the expected scheduling event counts", that patch is perfect. I think you more than proved the concept. Linus