From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2A29E71090 for ; Thu, 21 Sep 2023 16:01:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 294596B00AF; Thu, 21 Sep 2023 12:01:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21D306B00C0; Thu, 21 Sep 2023 12:01:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0975A6B00C2; Thu, 21 Sep 2023 12:01:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EB8396B00AF for ; Thu, 21 Sep 2023 12:01:18 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C3E97B42D6 for ; Thu, 21 Sep 2023 16:01:18 +0000 (UTC) X-FDA: 81261069036.27.1924748 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by imf04.hostedemail.com (Postfix) with ESMTP id 0E5EB40024 for ; Thu, 21 Sep 2023 16:01:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=HmUbovPF; dmarc=none; spf=pass (imf04.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.167.41 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695312075; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=19SW2gsLL1UdhsDBKiLlNxKkdUUQxSgCx6gW88i2Zes=; b=O6SLR5+sLS8Hd6dORTMeOrr6xqlpEP6m2wOlLiRFilO6VyVPVd+jhqZ9M7KYVMRBV5BvFw LDcUIEqUd+Ga8CFqwuWytnrzDJE2zPqBxfKHlQci71mcD/OSB++P1JEXHD1tOWx074eZnT oBvh5sELhRyTTIlv7w27fXaQ0515gl8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=HmUbovPF; dmarc=none; spf=pass (imf04.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.167.41 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695312075; a=rsa-sha256; cv=none; b=bMshIPapHgednaREC1OnSw3bB+YSqlvlr6sboWQMDwHoyGYGRVnbxDRuocPSK11gapbG1R AHSZS7ytz/CVxCrzgKoOeOLWJsMlxSF4B14b9Sqi+xnPJaE1WQep+mC/jQyFKDmKGgLCpO Y0xog1ix6KEhp6pfThGAUjdUBXDufSg= Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5031426b626so1890929e87.3 for ; Thu, 21 Sep 2023 09:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1695312073; x=1695916873; darn=kvack.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=HmUbovPF9YNjzJKxLrB/Bt/TYadZupnv2DPYv99CooOTe2QG6NUT88Or8VGCY3Rd5j QDOurZtIxqEvPueXQD075DQXMTIikk57vLKO6d5N1sDbA4QE6enGDdUztS99lfNRFTEM eMX/ph3mudm1PvXz2FJ6rMCiUK+KMWQXvOaHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695312073; x=1695916873; 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=tZ2Yb+RQX3ePXqmybDa51OL4FWJ5PonpPfaRXryWtLMsSgRE9Xk9gqpRKi0dmUw6Gg 02JWRBZ7aouzAdnYbBG1ATJVx3iAY4XoUtNb4pj44Zu9dahs9saM6A3F+hGUxZcnv6/i rXjocIN115MKqSpMQGTy+dsKxzCanb/QoXeMadoojxmXglQfxVG/8u/6x3vXidrol5hV 7aCqvZf2wUIrtLGe29DdJ/pg6KncR0+d0yV9p7T9xiNo8OM5vO+hdoUueBIJ6elqXkiV CQ+gGODSJwbc/K/xZHcIdyK834vznbVEfaPqXv4Umvl0OxseAciaeS8A4dgYxd9GF21R a0lw== X-Gm-Message-State: AOJu0YxR2hbLc5LxshbWQY43wA1BZNm5YuqCUhPlAWchWqnJTM+b1LPc vNpdWH61qS7+Mz9dvgAlm7qePYgdBADpfjHNlvPyxASs X-Google-Smtp-Source: AGHT+IHd8oMifX0iHFclidXqX04XPlvimuqDlAR1AXw9q8uyMOePt4N1wNOaiZRAIdo5/zIKTbVTQw== X-Received: by 2002:a19:674d:0:b0:502:9bb6:3aba with SMTP id e13-20020a19674d000000b005029bb63abamr5477824lfj.14.1695312072702; Thu, 21 Sep 2023 09:01:12 -0700 (PDT) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com. [209.85.208.52]) by smtp.gmail.com with ESMTPSA id j11-20020a170906278b00b00977eec7b7e8sm1253256ejc.68.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-f52.google.com with SMTP id 4fb4d7f45d1cf-522bd411679so1374923a12.0 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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0E5EB40024 X-Stat-Signature: ro8opwrtincngdacojnbsacgu1ee1u4i X-Rspam-User: X-HE-Tag: 1695312074-788611 X-HE-Meta: U2FsdGVkX19kRm1UNSU30CGIcgBPbsyYFf6YvyFCktHhl0HsFtlTJJ1aRnW8vbemWO2GLXZYZI6SHpXhvwYIiqbR3uwy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1Cupoll6LeBSe66W3IYGbB8kOlOe5dh6ed+kXvuJuxg8vtZh7s6TcLdpUcOkHegTAWwWd9s05sR1TR1dSNVhEho6bh4kLbEIGV4e2ScogwvPHob7t2dFsCAG0wB953pAlJ4JgmKau/YpxrSemwCUtRSCLZZ5rpU4fpVZE+41bMLK9aGDccdWjlXkqsXqB7E9gnoSmPBFBHYe2KagEBK0Ps2VpAGDwexRmp9zpSF6e15mlv3gjzMkCdBwiMW4CTzreY4lfAMi7vJI+f3Gx/J+AuBZPA8MfNjjB2KdhALJc8L4Xr1kNMg2kwHZuYwtv1DgRnjAJZznzesV2VFqoZZRvCIhm9nnOSrLg/oi6gPv2RNSit72A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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