From patchwork Mon May 15 06:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Wang X-Patchwork-Id: 93879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6701185vqo; Sun, 14 May 2023 23:19:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DuW1h1kMrrfl4N4fHEmAFNckpMB2/XkRD3eLZaxeH92Yit016EWBBhV1afp14y7Mpvu31 X-Received: by 2002:a17:90a:110f:b0:24d:f0e9:907f with SMTP id d15-20020a17090a110f00b0024df0e9907fmr43181092pja.6.1684131576904; Sun, 14 May 2023 23:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684131576; cv=none; d=google.com; s=arc-20160816; b=KHupd3mTM2L4IcLJb4s5IpD7jb1Rk3oXi6JVfSGNGvM3qJoQeO17T0Vm4vQhpBkl7X FVX9pdd8bFSqaqE2pJJ0Dh8inzbmdhS9iy+thzKJtbMHcKUkKcAvPlf9e5XUG+/pIOy6 Gq0Orx6qS0M5WmLhROmHr87YTJNCIJQzNFaPdOrOZ1YQiG02M3PDnyiGOAu1HihXWV+4 y2X0ppMgVpiWxj3L5jZkvy+PMnzABC/8GiBknsGibSC7+F6pjoCYbTgySA5WhtZHJ3Xg 1h0fdPtQBWo9BVBG559V7HZbrPbZtOgIMZNl65xAwuuUA/hUS+njmoqlg+hX82O0NJuc 9zwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=YDwXgP4aNVpWGdF7PEBCWW3b/GbMw8lshBPk4jXRrRU=; b=wOopelxpspkXN7vHd++OJ1jKATJ4VBXFUP3PdLZcfAKC6fT98B9+dqXpYhUNohVQ+F noKPuEMRuSuSjAA6epMQHZWtqOA+Wmb/9KRHXaIRt8JQVvLqI+CVyMD8ttmP/oe0I8uV UnLqojBsJUQMMMgJ2Vbu9vditAiIjze/+F6nt8x0dWGKW9+pH3ZV+SFCvqBj7+M7XG5L T94SZ/4DLRdJ0HlWK4CNC5iW2sHy/2PBasE8lqXfbJvVw864fx3JA1djufI0FQPVI7UH VXNteqDJO+sYlKBBCl3uAYv7D5PO/o4P7uCn3tmbiqo1I1bQjF/bCgI2/jMIn/6wXcfE 6csA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na14-20020a17090b4c0e00b00250aa670558si17212117pjb.43.2023.05.14.23.19.22; Sun, 14 May 2023 23:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238380AbjEOGH7 (ORCPT + 99 others); Mon, 15 May 2023 02:07:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239284AbjEOGHg (ORCPT ); Mon, 15 May 2023 02:07:36 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74EB630EF for ; Sun, 14 May 2023 23:04:56 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=shawnwang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0ViakDq3_1684130688; Received: from localhost(mailfrom:shawnwang@linux.alibaba.com fp:SMTPD_---0ViakDq3_1684130688) by smtp.aliyun-inc.com; Mon, 15 May 2023 14:04:52 +0800 From: Shawn Wang To: fenghua.yu@intel.com, reinette.chatre@intel.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] x86/resctrl: Only show tasks' pid in current pid namespace Date: Mon, 15 May 2023 14:04:48 +0800 Message-Id: <20230515060448.50446-1-shawnwang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765939952805446097?= X-GMAIL-MSGID: =?utf-8?q?1765939952805446097?= When writing a task id to the "tasks" file in an rdtgroup, rdtgroup_tasks_write() treats the pid as a number in the current pid namespace. But when reading the "tasks" file, rdtgroup_tasks_show() shows the list of global pids from the init namespace, which is confusing and incorrect. To be more robust, let the "tasks" file only show pids in the current pid namespace. Link: https://lore.kernel.org/all/20230116071246.97717-1-shawnwang@linux.alibaba.com/ Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files") Signed-off-by: Shawn Wang Tested-by: Reinette Chatre Acked-by: Reinette Chatre Acked-by: Fenghua Yu --- Changes since v1: - Update commit message and commit tags. arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 6ad33f355861..61cdd9b1bb6d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -726,11 +726,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s) { struct task_struct *p, *t; + pid_t pid; rcu_read_lock(); for_each_process_thread(p, t) { - if (is_closid_match(t, r) || is_rmid_match(t, r)) - seq_printf(s, "%d\n", t->pid); + if (is_closid_match(t, r) || is_rmid_match(t, r)) { + pid = task_pid_vnr(t); + if (pid) + seq_printf(s, "%d\n", pid); + } } rcu_read_unlock(); }