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 11722CE7A88 for ; Sun, 24 Sep 2023 07:19:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7529A6B028A; Sun, 24 Sep 2023 03:19:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7024A6B0295; Sun, 24 Sep 2023 03:19:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 618816B0298; Sun, 24 Sep 2023 03:19:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 53A326B028A for ; Sun, 24 Sep 2023 03:19:25 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1E8FC40A5A for ; Sun, 24 Sep 2023 07:19:25 +0000 (UTC) X-FDA: 81270640290.29.3100918 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id CAD31160004 for ; Sun, 24 Sep 2023 07:19:22 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fYulvVlr; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695539963; 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=jQog87/EAGD1kuKRgoTr1CslLjKeFhqkq6roBcGXn7U=; b=sJF9VJmW20vQes8jv/S6ZsAH4JyHbPdchI9pj6kvFZAmkJHHEpSN+j4Et2JpG67X6+VwD9 Kv0XVswppyJAZfF7yUgE9Z/3FOp3/neun9ykX3587On7bhFeQwwQUxbmWqfXcMkVu0Trz6 Yi9XesImxmMDUUUP9itI8NXrHaFIT4Q= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fYulvVlr; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695539963; a=rsa-sha256; cv=none; b=bahO+9pJv+1/9xaQREzNnlCjBfwj9Hv02tiSDtHoQISlRt3SwFyNa3Cc65BPAPO1dpkYwH 2C8hQNIWhqIu8HWkFKh/HTQhoOcAY2soWeaFia/ykgmRn5hhokoP891cP8pS4IshgykBO7 MqYLfyCagpnzUbhaJ/1QojYIXB+WSsU= 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=jQog87/EAGD1kuKRgoTr1CslLjKeFhqkq6roBcGXn7U=; b=fYulvVlr29MHtBp/H3NSYcHVp7 ZQlgDEDnWs+EhrE+v61h5mCrxCqb1oAQb68p3UU4nL2W/FxyRB52IOMzDBos4mg9ovJQhHr5bVSCi A3tRJV5s5AmFYqNSCEN6CWxDizZGMslMj1OhMC5avgzs3phHW0+/TJJBo47f6KAofU721Nrc9a1jQ 81tNZIjKJ43lcPlN2KRcUlH7kPdT/Xc7koFbMkJFVfx5/iw9ro9hlf9eG0Ny78x2cvq/5U7Hys38F 2ereuHO/zgWdjddDYq+D1tIl1QHm5NU9rV/E281QzHNDUKPVpYiQwZ+tTgX30okeYM+TWFwR/IaoA ybqhOyaQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qkJOS-00Bfih-3a; Sun, 24 Sep 2023 07:19:04 +0000 Date: Sun, 24 Sep 2023 08:19:04 +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: <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> <87h6nkh5bw.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h6nkh5bw.ffs@tglx> X-Rspamd-Queue-Id: CAD31160004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: e5bpstcgt9jc9ibg5d3184hb8sp3qh6e X-HE-Tag: 1695539962-543892 X-HE-Meta: U2FsdGVkX18HTdWadGxLef4O4u0Q0tOQF5H8eeUDSH/s654dqoTb5+FApBV5YnDLmZKmXMTut1KyfZAe9JLB8HQ0JclOda58c2GBtc3E2jEnYKM2gdAcT168K3XkYFUmDazgnHfqm9KrdkfCiQvxPLKS4bZEVzATDpH4satEGGZTYr5DkKzA3vKUdT0gpyzuK1eruZy2CQcnHYtNfYATjCh1g9nWsGYqZgkTBgS+qjn9Cm4id/0KtJ8scRTI1VIN7ixiKwrMD+lYGjE35ci9dEZenXDOIXl1fbOj841peM8AR1C9sz3rsAjQk/AsWcFj8fdfT7Ry1vFeoHztMYDF3fegffknTkISrB68nFvEV4ek37Fs3+KJnEC3rEqbrIIMh6c9EFz8+Se2oPCZrTR+3Dv00hG/Q4/7egc+eXP/CROWA19GxL2AFGiwTVEo8qIEnIdB4PuXNwg3j2ydlcvyCOA9xsjscoQz47mwvUzROsip30MhalGx3u938XUcXVV+9nydE14HpvYKj3SrtIdlni8qhhNNYctaJFOF8HOUbyhemXzLFE3G+U6lheD3JaDP+NIAOnfP5FLcnL7BLxNSiM9NOP3Z1HEKbWPO9dE2Ovid4/GS5ckj22NEkBBmXnSgXxCVs/Ah8Q/LYCXiOtNOFwHwyIIgcvnxql/+eZZB0kxMcar1RdZ3lLqPv27+JCtanvLpA+DAqPLQSVXPxfTZa361iraCAWtJL4vsQ3Z6qF8qyVxGYTo5kH4moJxQtILtAfaLWjiZNTc3cyq5uCCTF7Ocu4+6Vni27n7NeVvfp8E3MIgZ073ZUEXY8Ciup4NiIGj4V/gHJeQmrUbv1OBIy0iEQtirE+2oC6cVXNT7rI3hUR76+hOFMm19bl2Hg+YD09ZvHI3brSIXecXHbMR8nOeWuwIF/fBDtuFdeDz5iGTiGGw2lziGbEOiSTeLvTtWMq7WT3D68gM7ypESFxL SwNUnqP3 P7eEffaOAbIF3oLCnhGt4K26LdV3QV4a0Bw94s6zzfmzyBGsZZMbgrVQb5sAzfOIlpUTGBvCPM54wUR1CYTazC0b97uGY4J4E4hcsc4eHRmMWVF+wG09YqHAAPg4D6x50waAsG8igx+sxaOqcGCwh2xXonwEll4VsB2tZCtnxwLjcDc3bENIm+w35tw== 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: 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(). eg xfs_prepare_ioend(): /* * We can allocate memory here while doing writeback on behalf of * memory reclaim. To avoid memory allocation deadlocks set the * task-wide nofs context for the following operations. */ nofs_flag = memalloc_nofs_save(); /* Convert CoW extents to regular */ if (!status && (ioend->io_flags & IOMAP_F_SHARED)) { status = xfs_reflink_convert_cow(XFS_I(ioend->io_inode), ioend->io_offset, ioend->io_size); } memalloc_nofs_restore(nofs_flag); I like your other approach better, but just in case anybody starts worrying about turning a bit into a counter, there's no need to do that.