Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3531682imu; Wed, 7 Nov 2018 11:47:19 -0800 (PST) X-Google-Smtp-Source: AJdET5efi1eMsQvzGg3XC9EHJIareZktSowoR8bmOfuxdplM6YtRB3wIGaESly+vtMf1qOS91N0s X-Received: by 2002:a63:ee4c:: with SMTP id n12mr1308324pgk.21.1541620039105; Wed, 07 Nov 2018 11:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541620039; cv=none; d=google.com; s=arc-20160816; b=RpfffZVcMzpBi/SzHSklEwXzyftWA9EDm7oxRtk56SjTRazgUStcYzqWhMpbJJam+h UUthq5/cg//Mo4y7ReQ9CpIowdNKUaZzyoGurXROLlR+6bm1jMJbs7UvaKRT5PszPnuF IHyhpvv76CI8v403Gg0BW1+kViksnE3q5gD5s4YLluJC87WrE5Qfj1aaJcS7NbUuRdxY ywPZ/0aCh9JbnwqCF8poNLMhVO6pP8Py2j07HevG6eBNHlQaLOx7fmETFJ11gh5TrFZ1 LcsfII0Cip274IjJ65sM0aYi0H6fBSJCsZgG0Ma7o5zUwk2liyToV/e6TVROxp811HIF u/Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:subject :from:to:cc:dkim-signature; bh=WX4o1b9CfavJF7tL72poCIr5V1AP6JICSuMh15MN7FA=; b=BmojIIn/+0eWftg/CORfcAkVpAQgjTL6iqL5YegNz6Bu61/sO7wD0bWHeW5waZGzVV pz0FnJLjs2H8ZspyakXZRl/48T/zIAAhdOQ4rHkkxt7mNpM/lrTCGrZk4ijxnvFBU0LW MYKukW3Bll6zIo1OMm7Taq1BHCFLwaLL3BlMFqisXqvpK5/gGJHZC/c6wBA8PvxmwHUE kN+A1i6BACVrARypUSZuKLTC5nhys3bTybufO4bIMuxpRMXG/bPgdWtZpGZgD/rLhPGn OXcwo9o97nO57DiiEMcsCMDu4gfx1L8kOZS9SzCpcOyj5G2TrpBfBXohQ5ZMqZtwz8d/ +GyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="toGPkD/u"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si1451408pgv.397.2018.11.07.11.47.03; Wed, 07 Nov 2018 11:47:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="toGPkD/u"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbeKHFSW (ORCPT + 99 others); Thu, 8 Nov 2018 00:18:22 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51441 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbeKHFSV (ORCPT ); Thu, 8 Nov 2018 00:18:21 -0500 Received: by mail-wm1-f66.google.com with SMTP id w7-v6so15211732wmc.1; Wed, 07 Nov 2018 11:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=WX4o1b9CfavJF7tL72poCIr5V1AP6JICSuMh15MN7FA=; b=toGPkD/u9gsg5XYh+1AjF+hDC5yB4AYYOI/hIgwSp6LaV5gIj6TAGcxovhEq6l2Vmt AdwEWMmSICVS5svbYv7QvgMEnFI+cO9TYWG95OQHsQ1N7Nd9tEHeUmqXPWCuXi8LpTrR 6GQuGbyAQmIjT7VLOCaRfYOCoxUmFqKSJK94nhuIQX8NaEOyZH4ay7fObNflqi8WXji9 ouWTFoNKzd3vlUXR+bw744TeG3eN2IaOw+h+uW09I7B915DQ/DlhrvFO5t8pQDJPxCzl QbrLsZwK44f7KcR+/kpJqhLi4J4Ifc4tsDM9zNw1G8d6+fq3UX4/GvKgXcM231t2WFUs Nctw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=WX4o1b9CfavJF7tL72poCIr5V1AP6JICSuMh15MN7FA=; b=he0/XaJ2M7ohtP7bV50FT0swyYCYx4+/ELl2sVMqEX21cOK5I10fsUzBoYBnBhTd+W 7PClWs1yk44ZLETYlD8J7tsCBusk7ZMnffTW4Eop/gV/rlJBq3Cy46oW5s5La/b5yfjm dI5zyzhyRUxLurocG3aJwSkL/jD+jzRvOTEK9uM9+3r3vjrWFEql+75hZYzct0kVyY19 63rPUpPJWL7wUiJodxj3hemo2HIJmPArUpZ1EDLtRmOiZNLGzEzlXLQup6V+HvXlKT9U cYopL5bYIgQ1LoEJtih9Hn/rZVMzJ6NXXJdiEK5qMiOtXOc9uYI9GhjuYZnT/eQ9Hoef /2hQ== X-Gm-Message-State: AGRZ1gJ7X+K4XpzG+Wwy+NULcifrgHVIuZkRu3manE9yuEEE8G7uYdW5 VcIshuIie+/hc/wbKME55CEdZdAZ X-Received: by 2002:a1c:bce:: with SMTP id 197-v6mr1254936wml.15.1541619991273; Wed, 07 Nov 2018 11:46:31 -0800 (PST) Received: from [10.0.20.223] (mail.jambit.com. [95.157.63.22]) by smtp.gmail.com with ESMTPSA id r3-v6sm2437218wmd.25.2018.11.07.11.46.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 11:46:30 -0800 (PST) Cc: mtk.manpages@gmail.com, "open list:CONTROL GROUP (CGROUP)" , lkml To: Tejun Heo From: "Michael Kerrisk (man-pages)" Subject: Cgroups v2 bug: incorrect reporting in "domain threaded" cgroup.procs file Message-ID: Date: Wed, 7 Nov 2018 20:46:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Tejun, I've discovered what looks to be a bug in the reporting of PIDs in the cgroup.procs file in the "domain threaded" node at the root of a threaded subtree. The following demo is on vanilla kernel 4.19. Suppose we have the following multithreaded process: $ ps -L 654 PID LWP TTY STAT TIME COMMAND 654 654 pts/12 Tl 0:00 ./cpu_multithread_burner 100 654 655 pts/12 Tl 0:01 ./cpu_multithread_burner 100 Now suppose we create a threaded subtree in the v2 hierarchy: # cd /sys/fs/cgroup/unified/ # mkdir -p x/a/b # echo 'threaded' > x/a/cgroup.type # echo 'threaded' > x/a/b/cgroup.type Then we move the multithreaded process into x/a in the threaded subtree: # echo 654 > x/a/cgroup.procs Now we visualize the set-up using my visualization program[1]: # go run ~mtk/lsp/cgroups/view_v2_cgroups.go x x [dt] PIDs: {654} a [t] TIDs: {654 655-[654]} b [t] The above is as I expect. Now, we move the thread group leader (it has to be the thread group leader to show the bug) to a x/a/b, and again use my visualization program: # echo 654 > x/a/b/cgroup.threads # go run ~mtk/lsp/cgroups/view_v2_cgroups.go x x [dt] PIDs: {654 655} a [t] TIDs: {655-[654]} b [t] TIDs: {654} Note how the *thread ID* of the non-thread-group-leader (655) is being reported in the x/cgroup.procs! And just to verify that this is not a bug in my visualization program: # cat x/cgroup.procs 655 654 Your thoughts? Thanks, Michael [1] https://www.spinics.net/lists/cgroups/msg20710.html -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/