Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp716746rdh; Sun, 24 Sep 2023 08:36:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHmNJoRqPtLM9LWXEcyv7gsWbJLuAs3VfJAi9qDXMLpSWmKAjTVfCFpSLQs4A4TmR72pnG X-Received: by 2002:a17:902:bb83:b0:1be:e7ba:3a97 with SMTP id m3-20020a170902bb8300b001bee7ba3a97mr4455752pls.15.1695569810502; Sun, 24 Sep 2023 08:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695569810; cv=none; d=google.com; s=arc-20160816; b=U4w2pd7S6E37tTA8orOjg5kgBLq4WZF3jrS/tlthen2tBtclthhp4GTfW+1ELomzcA Nt0fCWI0JGBIUY3oprApnXd2xAIZ3PX+G8ypLkbLdYGnjjPvzLgzbL1esdKTKO7tSS01 IIKKYTGa+25lnP3fd2iGHE+IqVIDMaD02sUv8v/8m0HYi5AsvD0WzXupCiNUH3QY797j r3tuhhr1SZ4Xk0R5/Oo9x855K/UtIymEJCbmfUbaDNUbtVAHw9tETfrsndaMk0+tQ6TG cwNRZOcUBX7dih0OSMYoVQnTAcjwK21yAfNXinnlkJWmCAHdscOdR3Eu1JQtOhEPMXZn kQag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/3akVz7429yUkO74jWnqSj0RP1sGbx4CbguPmd6QR70=; fh=to4qkHAYXrgCJ72daCzaeOfrJ2y3xdV2MlogT+EZy4E=; b=vK426aCtf5aRuFWCXHnPmaptVNxHyHbeM707QLIoEVr/yGq07vrYqSUfln9LLCLjOe WXPdYog3ynS9cAMkc0N8LLeIb1u79bYXYCLvPHi/q2/JdWn/SV//d8Xp28rwW4JeeJku 8H2hJF7MCJ9sWFweFzzVRF0Hnh3/HRDfOJPRuOm6jaSLxVHfY/l9GiHwKJbffBCcBuzR ARUAL3CHQhD9lbMs1IVvGyCnJ9AYgIpZtERgxG0sq2lvUkKpt1yi4drsAcVVRf3yOKSB rwmzVZ/d939zX8DqOO05Gbh2dtJPh7zNP0I9YdUi/B7Ue54kDiq6NEpM6VdJEUm5ifWu Inug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YFSyx6fR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id lq13-20020a170903144d00b001b9fb1a0465si7527293plb.385.2023.09.24.08.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 08:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YFSyx6fR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 1943D80C5F90; Sun, 24 Sep 2023 03:29:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjIXK3S (ORCPT + 99 others); Sun, 24 Sep 2023 06:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229937AbjIXK3Q (ORCPT ); Sun, 24 Sep 2023 06:29:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6A39B for ; Sun, 24 Sep 2023 03:29:09 -0700 (PDT) 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=/3akVz7429yUkO74jWnqSj0RP1sGbx4CbguPmd6QR70=; b=YFSyx6fR2RkEKaCzXGxU3s8hJi jo97uZO7CJBoAMZsYTEwrHWKB6UKHknoW8qNrYwtqnuHe6MZ6HE7UYLpP+kAaea/P4AwH7f0vdnyZ LhqrbgzhX43Ef/2v74a7CXWgWjFDF4gr2gzrRdBU/y1MRIeFxFPfpGg/6cKsRgOcImkCIkMTqi/La De6QZ9ZfYuYfqYbL97Qa0akIxqu0+HdFxZDZ2y0cYCKxu9z2NPDPsGL6TKLzywMp4SIoUK3G7j9ez qDGUco0haDrlv3IcQB4R0DDXiiINXiNzh5nHPDUWueRPtY05wSqgr91EKF6onMlXpDQcW2Uclkt2n 9nE6YiyQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qkMMH-00CRQV-DX; Sun, 24 Sep 2023 10:29:01 +0000 Date: Sun, 24 Sep 2023 11:29:01 +0100 From: Matthew Wilcox To: Thomas Gleixner Cc: Linus Torvalds , 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, 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 Subject: Re: [PATCH v2 7/9] sched: define TIF_ALLOW_RESCHED Message-ID: References: <20230911150410.GC9098@noisy.programming.kicks-ass.net> <87h6o01w1a.fsf@oracle.com> <20230912082606.GB35261@noisy.programming.kicks-ass.net> <87cyyfxd4k.ffs@tglx> <87led2wdj0.ffs@tglx> <87h6nkh5bw.ffs@tglx> <878r8wgg3b.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878r8wgg3b.ffs@tglx> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sun, 24 Sep 2023 03:29:17 -0700 (PDT) On Sun, Sep 24, 2023 at 09:55:52AM +0200, Thomas Gleixner wrote: > On Sun, Sep 24 2023 at 08:19, Matthew Wilcox wrote: > > On Sun, Sep 24, 2023 at 12:50:43AM +0200, Thomas Gleixner wrote: > >> cond_resched() cannot nest and is obviously scope-less. > >> > >> The TIF_ALLOW_RESCHED mechanism, which sparked this discussion only > >> pretends to be scoped. > >> > >> As Peter pointed out it does not properly nest with other mechanisms and > >> it cannot even nest in itself because it is boolean. > > > > We can nest a single bit without turning it into a counter -- we > > do this for memalloc_nofs_save() for example. Simply return the > > current value of the bit, and pass it to _restore(). > > Right. > > That works, but the reverse logic still does not make sense: > > allow_resched(); > .... > spin_lock(); > > while > resched_now_is_suboptimal(); > ... > spin_lock(); > > works. Oh, indeed. I had in mind state = resched_now_is_suboptimal(); spin_lock(); ... spin_unlock(); resched_might_be_optimal_again(state); ... or we could bundle it up ... state = spin_lock_resched_disable(); ... spin_unlock_resched_restore(state);