From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06FD921D591 for ; Wed, 12 Aug 2026 02:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786501313; cv=none; b=BfU3oUNMKGDzsQEwRS3DVcYCfFokaBLVF10B7b6nZ6j11C6zcXywfo1RS1sDVpdZdZmQyE3y/DT2bUabjedlJGqBztp1TlR73kEyB+zqVylrkC+YuAcXHldvoyGvxNnF2fBt5xGn2sNXrkwIyhhYPudKrzv6eKdJZLOTp3ExGiE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786501313; c=relaxed/simple; bh=D8wurMWwA+iesPLW5dKFUX2nYIRisWzR32LVwlY0qCU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=B/iUrHEkyt5NI7wGy2AxLnW0u5B7Gq/Sx0FpWWqfjuf1ctQUYrvndbaax2onVIy0NABljLPmV/StAQkibC8FnRGzI052rRk2ayZxyRKsds7K87w51WPznd25zZRaKgbdlp8Jg9qvKw5Hi29mnkEIPMUXRexDwaCEsSmp8RZAjzI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mEX/slLj; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mEX/slLj" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2cc891373e0so8467345ad.2 for ; Tue, 11 Aug 2026 19:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786501311; x=1787106111; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ZVW1ijqQrdC76KPxd1P+wWfk6mc6/kmDPQ77oviSzVY=; b=mEX/slLjnIP38E2stTK6YaZ00wMdZs29mLu/8dRTGLX59ZuJ2/ei6YagBioX9rSWdd i6yJfXDJWSc7HrxKWZPP9w0kMZs6ZN7zkJXDA+Hz5/ucoJnWUXnGQySzWwDnmGzkepza 7oGB7PJMyA6e2kfXsj6d4eTtnSLtq46aVy6d6cdWS7eeDTIrQgjD7UFXlp8H4L51LnHt UAYrhEMWzBaooNd+04wrN0vIfHv3WqFVTeLoQ5j/BwJnmIDBLLOZwsFTJgPLwt+/Iewg lhl+xySYdU84HlUfflivGQxmAkKzkkVqmw+JYrDOTppFH4grcm1QyLTCVNrGekM7h1ac YZTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786501311; x=1787106111; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ZVW1ijqQrdC76KPxd1P+wWfk6mc6/kmDPQ77oviSzVY=; b=ZhhU1A1qNNYMwiM7EcMmuXghUwf3Nw9vC6VdqnfHDKPNSgzQ6RcysEOEj1J29gHkd2 Ox8hpdoVBlByc1KPAHEkXW5vWWLhVLQajpHeAd9fJoErsZ1zQTrR7zD15hoxwgzs54JV NcBq8NSfVZn6b3I27w27qvhpLI0JroPNxIxnNgyeugJvrXIDK1R921noq+hOfVlWC+IW xSuwxkpaud8DdQw6ciu2/dDn+4FLmEagL01M0QPLTTxbiBNz1UrvMt7JvFz2jpMiA+s3 3vSqFPpvLBaHsJKQMKtf/wK2FjQYW5JIH0NP2AGhhsUjpDHyvwRHZtfWXwdypE6qUTdC hviQ== X-Gm-Message-State: AOJu0YwFVIHEwI9TbMVvHdixf0XVv+947Cl8gOVzn40hTgfmyj2C84q8 jS2vhgDDsCCrPJhfCVH8S9s07+LJgWKvoc7q9s89G+SSbLcT3bIv6PHt X-Gm-Gg: AR+sD12Y0nFVXzzAkwSLOUTcUh+3d3zxVVvaewRTSycv1V6DQ0wAUl36c5qASz9qYCF 83SlD3f5RRmrVlTi0Irj7ia+T2h1GsZHaVqlkq3neNAE7j2P8PcB+w8TSI8NwjXngjSz+jTBF4A Bw9Da7ozNCX88I7FmZQGzzqIxfzhuhCHOXWsSkNmftsc34nRvHPmejY5N3ikLQFSq8SYRuykfRf xPdQOCmnQsxe08yhxcWVvCeVAIJ9wF9WvCpghGJASSK0OQjyS8fugd2Hi2eggMv4xcTodVw1rCq sERTQzQ1+1Bgdogtd01sMWGm/OX8GgDdj5f4adGBi4aAvP0Whf1/TPIes2n8CbhZ63/LTstAVPx xtV9YZbDhCATMt//uWFYGTw/yyGduk91Wwkb55mKoaxqzg3pLkZWvSoYWEHfxLmQn5R84BcdihW FtKaxQNDrFu/+S6eyFs3X+qJBZE0xU2QrURJByEfjOP5Ixpi9MMgl5yydKWX2dYMnFUXDO1xmoS V/T X-Received: by 2002:a05:6a20:94c8:b0:3c9:1c1f:f516 with SMTP id adf61e73a8af0-3cc3f72f434mr1561689637.19.1786501311192; Tue, 11 Aug 2026 19:21:51 -0700 (PDT) Received: from atom0118 ([2401:4900:894c:26fd:c399:880b:9031:4d85]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1412458461bsm6820079c88.13.2026.08.11.19.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2026 19:21:50 -0700 (PDT) Date: Wed, 12 Aug 2026 07:51:38 +0530 From: Atul Kumar Pant To: John Stultz Cc: LKML , Peter Zijlstra , Juri Lelli , Valentin Schneider , Connor O'Brien , Joel Fernandes , Qais Yousef , Ingo Molnar , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , K Prateek Nayak , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , Andrea Righi , kuyo chang , hupu , kernel-team@android.com Subject: Re: [RESEND][PATCH v31 8/9] sched: Add deactivated (sleeping) owner handling to find_proxy_task() Message-ID: References: <20260807035232.1881495-1-jstultz@google.com> <20260807035232.1881495-9-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Aug 11, 2026 at 12:56:53PM -0700, John Stultz wrote: > On Tue, Aug 11, 2026 at 12:09 PM Atul Kumar Pant > wrote: > > On Fri, Aug 07, 2026 at 03:52:14AM +0000, John Stultz wrote: > > > +static void do_activate_blocked_waiter(struct rq *target_rq, struct task_struct *p, int en_flags) > > > +{ > > > + unsigned int state; > > > + struct rq_flags rf; > > > + int target_cpu = cpu_of(target_rq); > > > + > > > + scoped_guard (raw_spinlock_irqsave, &p->pi_lock) { > > > + state = READ_ONCE(p->__state); > > > + /* Avoid racing with ttwu */ > > > + if (state == TASK_WAKING) > > > + return; > > > + > > > + if (READ_ONCE(p->on_rq)) { > > > + /* > > > + * We raced with a non mutex handoff activation of p. > > > + * That activation will also take care of activating > > > + * all of the tasks after p in the blocked_head list, > > > + * so we're done here. > > > + */ > > > + return; > > > + } > > > + if (task_on_cpu(task_rq(p), p)) { > > > + /* > > > + * Its possible this activation is very late, and > > > + * we already were woken up and are running on a > > > + * different cpu. If that task blocked, it could be > > > + * dequeued (so on_rq == 0), but still on_cpu. > > > + * Bail in this case, as we definitely don't want to > > > + * activate a task when its on_cpu elsewhere. > > > + */ > > > + return; > > > + } > > > > Hi John, > > one doubt, can It happen that this task 'p' has already finished running > > in between the time when it was was picked from blocked list > > (activate_blocked_waiters()) and this function? I mean, is it possible > > for 'p' that task_is_blocked() is false? > > So, I'm not totally sure I have in mind what you do, but yes. Most of > the conditions we are checking in the above are dealing with > blocked-waiter tasks being woken up in parallel with teh > activate_blocked_waiters() logic. > > Are you suggesting that we should include an additional check on > is_blocked before we do the activation? > > I guess I could see the concern if the task was woken in parallel and > ran and and then went to sleep (so its not on_rq or on_cpu). Normally > spuriously activating the task wouldn't have much impact (it would > wake, loop and go back to sleep), but I guess there is the risk here > that since we're activating it to be a donor on the waking lock > owner's rq here, the target_rq may not be in the donors affinity mask, > so that could be a problem. > > So yeah, it seems an extra is_blocked check is probably warrented > here. Thanks for pointing that out! Yes the condition you described above is same that I was trying to convey (affinity mask may not contain target_rq). We can probably add a check to confirm whether the picked task 'p' is still blocked or not. Thank you for taking time and going through the comment. Thanks, Atul > > If that wasn't what you had in mind, please do let me know! > > thanks > -john