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 X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B334C47089 for ; Thu, 27 May 2021 15:05:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 237086128D for ; Thu, 27 May 2021 15:05:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 237086128D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UyN/Bg8gFAhLLmFEbmWxsH/rlpy2w8v8qmhkzYbm5sk=; b=gejqeQhR/PK+cK 8aIwR5vIvs7Cl7ziZXyyc78/jNdVu4sQBRI8HQerh0y1+LTO1UoNZ5ZGAhgATTpyJuy4tATnQ2JdH 7x3IBtW3Myeb/PpBJ8oU2yZskHMBLY8vBxrpamM0Y4GrhLyVDWJPBXurYIsb+/plQGqDY5qtVOxKE xEnIp1SiL/Hv0dU6rtgnFpnLO/pi7uXpjUHUkaZPAyt/bbiv64oGqRM01rsmAhw2HNX5LgG7QQb90 94Q2aszxhXcn4GnrG9IT2J5osPl9sOmZN5NVC18KyQMWlSsVLOmiaee0EgO7gOxlyDIp7jDAXlGf9 TxBmavhepVv3yfbsHJpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmHX8-0070Wt-PE; Thu, 27 May 2021 15:02:52 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmH8E-006q2C-0l for linux-arm-kernel@lists.infradead.org; Thu, 27 May 2021 14:37:07 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 92D22611AE; Thu, 27 May 2021 14:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622126224; bh=j3oO2WMkdw8E5RxV/xTsNs7cKG+L3BAICIgf/n3PQ00=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tod3tbhDBUe2F+HRQJn/kDud2qI4/v+oiF0PpkgOzmdQxk+xKBIICLBp3st2ukXhM T+gTxGYckUjj6rZfj0aU0IXKarWsAx3pTJNneZO9A+7VyG4f6zBw+K2GxHHoRNieVt NsZUDc0FlU3iQRl/+gVCfaq8oifIncLwmPNNHzw5JPWeXMOCvegxEOuitrBhp/PJxw PpsqOVjLcOKg5h+HUSJ/NtTMYvKP+KHet1yF48zneltYVtumLwGGX4YOmacQN7KfTi JWvVx5YKjqAMuEiBPS/W/tkSHFR1w8a42nbSqGgEnsat4mec/rMwP0qnYvmUyCFwg5 HbvOlCerYwNiQ== Date: Thu, 27 May 2021 15:36:58 +0100 From: Will Deacon To: Peter Zijlstra Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Morten Rasmussen , Qais Yousef , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , "Rafael J. Wysocki" , Dietmar Eggemann , Daniel Bristot de Oliveira , kernel-team@android.com Subject: Re: [PATCH v7 16/22] sched: Defer wakeup in ttwu() for unschedulable frozen tasks Message-ID: <20210527143657.GA23086@willie-the-truck> References: <20210525151432.16875-1-will@kernel.org> <20210525151432.16875-17-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210527_073706_153945_7CD06C31 X-CRM114-Status: GOOD ( 24.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 27, 2021 at 04:10:16PM +0200, Peter Zijlstra wrote: > On Tue, May 25, 2021 at 04:14:26PM +0100, Will Deacon wrote: > > diff --git a/kernel/freezer.c b/kernel/freezer.c > > index dc520f01f99d..8f3d950c2a87 100644 > > --- a/kernel/freezer.c > > +++ b/kernel/freezer.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > > > /* total number of freezing conditions in effect */ > > atomic_t system_freezing_cnt = ATOMIC_INIT(0); > > @@ -146,9 +147,16 @@ bool freeze_task(struct task_struct *p) > > void __thaw_task(struct task_struct *p) > > { > > unsigned long flags; > > + const struct cpumask *mask = task_cpu_possible_mask(p); > > > > spin_lock_irqsave(&freezer_lock, flags); > > - if (frozen(p)) > > + /* > > + * Wake up frozen tasks. On asymmetric systems where tasks cannot > > + * run on all CPUs, ttwu() may have deferred a wakeup generated > > + * before thaw_secondary_cpus() had completed so we generate > > + * additional wakeups here for tasks in the PF_FREEZER_SKIP state. > > + */ > > + if (frozen(p) || (frozen_or_skipped(p) && mask != cpu_possible_mask)) > > wake_up_process(p); > > spin_unlock_irqrestore(&freezer_lock, flags); > > } > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index 42e2aecf087c..6cb9677d635a 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -3529,6 +3529,19 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) > > if (!(p->state & state)) > > goto unlock; > > > > +#ifdef CONFIG_FREEZER > > + /* > > + * If we're going to wake up a thread which may be frozen, then > > + * we can only do so if we have an active CPU which is capable of > > + * running it. This may not be the case when resuming from suspend, > > + * as the secondary CPUs may not yet be back online. See __thaw_task() > > + * for the actual wakeup. > > + */ > > + if (unlikely(frozen_or_skipped(p)) && > > + !cpumask_intersects(cpu_active_mask, task_cpu_possible_mask(p))) > > + goto unlock; > > +#endif > > + > > trace_sched_waking(p); > > > > /* We're going to change ->state: */ > > OK, I really hate this. This is slowing down the very hot wakeup path > for the silly freezer that *never* happens. Let me try and figure out if > there's another option. I'm definitely open to alternative suggestions here. An easy thing to do would be move the 'flags' field up in task_struct so that the previous access to state pulls it in for us. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel