From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.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 1789E364EA5 for ; Wed, 22 Apr 2026 19:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776885356; cv=none; b=FJxsfF3KJRCdoq6IMqS1hGGaCLiQ7RoMwKADxOcncbR+amUsGqszvxy5ga/ItP+5lENFk3C+sEjQxc/t0zXTcl/MZqeBNEtDGFSBRvxDoXvCgjeN3mE1VOoH1JwwWLxF3f1irnk+XM6g5FAISvxcGsT+txU4rknizDVz5UXKQC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776885356; c=relaxed/simple; bh=K46wLRQLJ7Hzb3HS4jLXpFrNo1DeVw5lT/nBhkxQuUc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NhpGQvuYhWlpm16+6PS4PFGvH+7PteN8GxXyNVO1C12QiFWJ67uTtynu3X7r45qvnQCM6eZiAVglWXQj1e1XdnrB2TZZsoBWSG//Jtz3UxhCOZ+39Xh+tuDjgRdlbnBUxiPKIIb3wzFECL/pZ5nZr/LZFQUiqICOSXanF3RGU2c= 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=m/5x4mfA; arc=none smtp.client-ip=209.85.208.171 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="m/5x4mfA" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-38e68e4389cso62067651fa.3 for ; Wed, 22 Apr 2026 12:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776885345; x=1777490145; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Tss2NFnS4WNHYKs6+Pb3NhQ3BMaMcw1cNRiwvfWC6Qw=; b=m/5x4mfANFUiC2TZ/zPPxwCYZZ4XMQAOP0XfyxW2t95PCiUEtaz+Pntl1601r/Aqtn sHvVUz7n3ejZt9OwnamjmmYuk6EB6xnJ1pasUo6Qob5fCkkaNtRf1MNJPGd67vNhaGtF 4iG5U9vI00HpQXtEYTXhKskS6PiSfyROBeTDH57cCUxPD0mIVvaX+qmcgDU54N/uwwlq 7+ek464haHWL8gLgql9KlkpJ5/n8E5Y0eeIxwDNs2eu7JvzhcOX7fsMLwbABWgKx+Ipj CJpZMxMqd7bw3R20vnq3k15EWM51izb1HcB/qeS3xkZ7Dd0rb0tg+7X5UmT3jLQGMIOQ LgkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776885345; x=1777490145; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Tss2NFnS4WNHYKs6+Pb3NhQ3BMaMcw1cNRiwvfWC6Qw=; b=Mzzak2VpP1+hYL8UprghOK1PWR7KTxuverMps0FYj37f+XSL/2tGoCWefsv5MT6PQK f9WMLRE3880DG3hGqNlIWRAN12Pbfqgu18kb/4l2YGlM7fo8c5+ano3XL1PP04P31LQN ytI2wr734OThIOK1r7ELQmTNtJqO1A1bpOsum5HVht9tbiUbUtpnDGyaz5DUPSieQoeY dOD0SqPmg0GNuPFPcO2qM9bb2+QhrMpVkXnNdZMX8xix/d16LhUHv3AWq99a+xD5ePd5 JmcweKym4nORCWKasqJUZSBQlhNVgCx/If3Wh1xVH+6bzYe3X0OxgbAd/9J45wNcWEBS Z0Yw== X-Forwarded-Encrypted: i=1; AFNElJ9LNs8ugdUdR+ZinqUtRPCpo1F1+jz9OhxsogT/EValxz5bQNmYT2BIbXhCDBGcIDGtsAdKRzx0RRhIsCY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywc/Nxc/JxUCpyguOtmfY8/xHf4KZ+nLwU6VegXWl9+kRd02Q2I 5jjp5Ddl8LUdMmHz6jeRDP1kG714Dvk4c17+0BdBK6zHRjgRNUaxWiM= X-Gm-Gg: AeBDietKIDoO0Q4FS/ZiV09gZEekqTOG6LoZmebfVe8nwEBgR12mcwucAp4izr56T05 mx3SLEY7Q8Rg4JFgSKwOajcsHvpPSREpVQCGlpWxgf0xVqgzODW7bTX8R7V9zzpJ70IAwCwbs1M uQJ0SRlWPWbwVFF/ZCZyxswMp7zfKD5UjPEPd6TP07gjDB0ImHoH80V/J6CAgwS7laIpXhFqrlj dSiWFXqNL/D1rHTsfCtgaVR8mp6WX2DY1s96J6dDpt0Ku8E2gELUsN2AIDcZ0VB/9BIkO5NNF1x i8660BbQhOOu5wCXTJZrPPO6QqQpCctAHtcoS7Yc2ZLEft2sk2df2HBybjtXojvO6WBUpLkNyQQ vLo1WNCuYnXn6joHabsRMYInZxKnjL2Kqx7zX9tFj3P0xPP18+SQHweLcuJlHX6Boa2SYT0BAhv uVukIfokmItdERkz9HiIkEkg== X-Received: by 2002:a05:6512:234f:b0:5a4:304:43c9 with SMTP id 2adb3069b0e04-5a4172ca2femr9225060e87.14.1776885344645; Wed, 22 Apr 2026 12:15:44 -0700 (PDT) Received: from p183 ([178.172.147.87]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a4185ad108sm4640295e87.3.2026.04.22.12.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2026 12:15:44 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: adobriyan@gmail.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, ebiederm@xmission.com Subject: [PATCH 1/2] proc: add tgid_iter.pid_ns member Date: Wed, 22 Apr 2026 22:17:44 +0300 Message-ID: <20260422191745.435556-1-adobriyan@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit next_tgid() accept pid namespace as an argument, but it never changes during readdir (which would be unthinkable thing to do anyway). Move it inside iterator type and hide from direct usage. Signed-off-by: Alexey Dobriyan --- fs/proc/base.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index d9acfa89c894..f2db455dbbfd 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3543,8 +3543,10 @@ struct dentry *proc_pid_lookup(struct dentry *dentry, unsigned int flags) struct tgid_iter { unsigned int tgid; struct task_struct *task; + struct pid_namespace *pid_ns; }; -static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter iter) + +static struct tgid_iter next_tgid(struct tgid_iter iter) { struct pid *pid; @@ -3553,9 +3555,9 @@ static struct tgid_iter next_tgid(struct pid_namespace *ns, struct tgid_iter ite rcu_read_lock(); retry: iter.task = NULL; - pid = find_ge_pid(iter.tgid, ns); + pid = find_ge_pid(iter.tgid, iter.pid_ns); if (pid) { - iter.tgid = pid_nr_ns(pid, ns); + iter.tgid = pid_nr_ns(pid, iter.pid_ns); iter.task = pid_task(pid, PIDTYPE_TGID); if (!iter.task) { iter.tgid += 1; @@ -3574,7 +3576,7 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx) { struct tgid_iter iter; struct proc_fs_info *fs_info = proc_sb_info(file_inode(file)->i_sb); - struct pid_namespace *ns = proc_pid_ns(file_inode(file)->i_sb); + struct pid_namespace *pid_ns = proc_pid_ns(file_inode(file)->i_sb); loff_t pos = ctx->pos; if (pos >= PID_MAX_LIMIT + TGID_OFFSET) @@ -3592,9 +3594,10 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx) } iter.tgid = pos - TGID_OFFSET; iter.task = NULL; - for (iter = next_tgid(ns, iter); + iter.pid_ns = pid_ns; + for (iter = next_tgid(iter); iter.task; - iter.tgid += 1, iter = next_tgid(ns, iter)) { + iter.tgid += 1, iter = next_tgid(iter)) { char name[10 + 1]; unsigned int len; -- 2.52.0