From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 1A8A64FDE4F for ; Mon, 7 Sep 2026 15:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788796438; cv=none; b=Fp8sA5Rvq0hEEGLHuylCovH8+uH8TNQqZ4jhT8j7RbjCQmOkK4QYso2/4KFUYsHg5qNblxtRMfqJrIdAvkRkKLa1DR5nNmWkPUPuRCk0pHXe6Y1MZnmdcxCVeS114j3AjJo+SKH5qew1TCuBArSLy8BIPevo5Vi6kyLJKhwN0hM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788796438; c=relaxed/simple; bh=kdW80z8QSijQXKWXMTATEq/l6KVSa+t5CIJEX8QYy6E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PohjVIHjg4OhxMWfi8VcxFHSO8efCEIWu999J/uRnckDRRC1cFuH7YLz6IB157N9jyWa3+ukreTqOhnhnZ8Qowi54uHV9E0pjxxSHZi4/qvnuKlQ41/T9bogZgJwNSGYY6J90DdVq1H1QmdV9mHPbU+JOK9Ro1cA6XX0wqEvjOU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=Ct/qjgub; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="Ct/qjgub" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-939b5ded99dso34679785a.2 for ; Mon, 07 Sep 2026 08:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1788796435; x=1789401235; darn=vger.kernel.org; h=in-reply-to: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=MpjJCtF9a7Ao8JicOrb9fcW3ZU3uKqej/fz3Z0ryD7g=; b=Ct/qjgubq83YDJuMY08ToLOHwyKEQAwm5/0XgADGkzXP/clOU6nt0U4E2QnUwbl9Ym 4+G7A8NlhptRM84KvYs42cjxX0FLUrShBMnPRYud/Iy6CauD5sBoOmOCLhxOOXiDIe05 2AzWTldRciiRFeRxCDYwLrU3sVqlLqmsm23QSOMa0r41Ga53oGwtbc6Iz7SPupKP7msQ k8kAh0dn52fzlA3KbLMr3dJn95x5embEN/wOPU7Z1nwZkwB4hgqkaZh/dbr4JIDaB3gB lWciwpHEO2RE0uIh4WpGSQMfrYNwG3jq2xZ4qWc7HQx+wCfO5pp2mS8p9as7Cy6fGzZ1 F6ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788796435; x=1789401235; h=in-reply-to: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=MpjJCtF9a7Ao8JicOrb9fcW3ZU3uKqej/fz3Z0ryD7g=; b=HofRj8WRpFfuBR9wkgAwZ5jJrrslRM0aamlZnBIrcQ65SpgzGDn3Fk3n2AOmAQ4awr PiLBkzMVMDNy4/KmyBJSGiEudKH3xJpbviHhmr7kC1NjFyGfj+nEGbH8EpTN98y9FQCf wxYWEdr+deWqrZUe7uHmXLmJmY5UP2S0UQPBlsdPRVJa3bfJjMTqBOa4Bi9pwd+wWxY9 xBunqCBwEGzoPR7RqyySZU7tiBdgIk+BY7+Ct1fndsE/LP3SK7SHTFRMem3R+WF7iFqa G7bKGPRTL3sgwGzgwZNpuv6FmeBhQpCdg3xaIdREh+fa1FRFJXyswaKsiok/G+m+8yrP 3oXQ== X-Forwarded-Encrypted: i=1; AKwUvBwxBH43BNX+E4mLcA3oetCYz+BFpKy5fhiYI5YsL9BUmKVGSR9mK/g2roKZNWaSxxOwO5mZx8WQcw==@vger.kernel.org X-Gm-Message-State: AFuF++n3OoMln67Lqr40F/clgW3kjWPoh+gL55MovqPry3N0RgUjWkMG wWVsP0TvC8GI+msBa6Ft037qiz4pkMJqLyu3i5IzoXJTVdyInaJvVFM/KVvQWvLmVjM= X-Gm-Gg: AYBFou28490l/zgufN1JO6mOhdXKu3OwnwGlwlk+zdhYx5imF/iKZzd9nvub4zBZX+l tBW6KFSQUncR3LPPnLHS3zewzYibeO5mNxwchbVa9mzgDpYXlz3AJZ1kdb7rv/yIQP/nIGrDg1T bYcuuNCsVf89FnoX1vmltuUqESYspYeO86/IIPfB7J2OaZyaSSOq1LgN17jYOnp44M/t4HKIWiR pkATAd54MpVnYv4JiaD0cBxK2Pqd1aEC5T/6dtHK5Vlwbj0MQH/PhU/vOcTuiM8+Hnhce1fS6FV TQ+MAjL2egHmf49Q09RgEnCt84fdilzAXxaxZ4cunST2y02bXJ2rwa8WA2cTsDyEixna2fwJq1P 4k5jyyDJo5GPKsqBRw/FHyVmMCfiz2yS1DBSQ168q4ifGeqdSREb09RpmOjIE3M8QADgp6hskd4 IlcE6OqFYo38c1prRpKdFx9HXI9QMKMp7nSuHf9niFmz9xfIqmV2FjOVhz/5AlR+RWTgXAPFR1B AFj9UmddjWIDbsFT1UOEolkBdYi9PviuhCU53/i/diT X-Received: by 2002:a05:620a:851d:b0:939:6de8:43e3 with SMTP id af79cd13be357-939804cc15amr1836196285a.48.1788796434937; Mon, 07 Sep 2026 08:53:54 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9397fb59c72sm907982585a.26.2026.09.07.08.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 08:53:54 -0700 (PDT) Date: Mon, 7 Sep 2026 11:53:51 -0400 From: Gregory Price To: Ye Liu Cc: Thomas Gleixner , Peter Zijlstra , "Rafael J. Wysocki" , Andrew Morton , Ingo Molnar , Will Deacon , Boqun Feng , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Juri Lelli , Vincent Guittot , Steven Rostedt , Masami Hiramatsu , Josh Poimboeuf , Ye Liu , Michal Hocko , mic@digikod.net, oleg@redhat.com, david@kernel.org, linmiaohe@huawei.com, nao.horiguchi@gmail.com, gnoack3000@gmail.com, ljs@kernel.org, sj@kernel.org, rientjes@google.com, shakeel.butt@linux.dev, xu.xin16@zte.com.cn, chengming.zhou@linux.dev, tony.luck@intel.com, reinette.chatre@intel.com, x86@kernel.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, pavel@kernel.org, lance.yang@linux.dev, pmladek@suse.com, longman@redhat.com, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, qiang.zhang@linux.dev, dietmar.eggemann@arm.com, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, mark.rutland@arm.com, Dave.Martin@arm.com, james.morse@arm.com, babu.moger@amd.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rcu@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v2 5/8] kernel: convert process/thread iterators to for_each_*_rculock Message-ID: References: <20260907081334.1152889-1-ye.liu@linux.dev> <20260907081334.1152889-6-ye.liu@linux.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260907081334.1152889-6-ye.liu@linux.dev> On Mon, Sep 07, 2026 at 04:13:31PM +0800, Ye Liu wrote: > From: Ye Liu > > Replace the manual rcu_read_lock()/rcu_read_unlock() and guard(rcu) > pairs combined with for_each_process(), for_each_thread() and > for_each_process_thread() loops across kernel/ with the > for_each_*_rculock() macros, which scope the RCU read lock to the > loop body via scoped_guard(rcu). > > No functional change. > > Signed-off-by: Ye Liu > Acked-by: Michal Hocko Question below > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > index 6fcc94ce4ca9..73a5ad3be9a8 100644 > --- a/kernel/hung_task.c > +++ b/kernel/hung_task.c > @@ -315,13 +315,12 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) > return; > > this_round_count = 0; > - rcu_read_lock(); > - for_each_process_thread(g, t) { > + for_each_process_thread_rculock(g, t) { > if (!max_count--) > - goto unlock; > + goto out; ... snip ... > - unlock: > - rcu_read_unlock(); > - > +out: > if (!this_round_count) > return; > The sunken rcu_read_lock()/unlock() + scoped_guard usage makes this goto at a minimum very confusing, if not actually broken. Are we sure this isn't broken as-written? Generally we don't mix cleanup and goto for exactly this reason. ~Gregory