From patchwork Wed Mar 20 11:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13597194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01E75C54E68 for ; Wed, 20 Mar 2024 02:06:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 683EC6B0083; Tue, 19 Mar 2024 22:06:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FD7F6B0082; Tue, 19 Mar 2024 22:06:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49DCB6B0083; Tue, 19 Mar 2024 22:06:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 31D626B007B for ; Tue, 19 Mar 2024 22:06:13 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 035FC405FB for ; Wed, 20 Mar 2024 02:06:12 +0000 (UTC) X-FDA: 81915777426.04.BAD5FDC Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf24.hostedemail.com (Postfix) with ESMTP id C299018000E for ; Wed, 20 Mar 2024 02:06:09 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710900371; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=i5KmQjE+sXDX3dn3ojRf6tmhOa3+8oDGMkztHVX6hJI=; b=4MJ4+TZpEmGkYcYla/m5UwMETObjlHUICjEp2wKgiWCHrMJ9qQIfwZNL4Fpxc7dwvIxrKj sUeGTSx4X/UWwWNUVfDgtUr+Pmo2teDj26Bkp9+a0FCpzXUCXSe1C6TbaZOIZvHxx8jgV/ KHYLrOLtwqQ8gfMAPsHgYKiGIm66Vag= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710900371; a=rsa-sha256; cv=none; b=eh5J9RtY4e5/hyg3jlGWRea7FKhKUUsL/v4xEBgTI667kL3spRLzYCZOuH3M+12ZU59Jpl ziAlBjmOTHyRBxdMEcbZUbBhbO7rNobJkNQ1vMNeHEfXVhPcBE1bkE0V459z/loMj+Trp9 SJaUfedANNpk1iQVlvegQkBp64C6hGQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4TzsPy4Y9Kz4f3jck for ; Wed, 20 Mar 2024 10:05:58 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 9A3F31A019F for ; Wed, 20 Mar 2024 10:06:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP3 (Coremail) with SMTP id _Ch0CgAHFZ2KRPplVj2CHQ--.18626S2; Wed, 20 Mar 2024 10:06:04 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, tj@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, bfoster@redhat.com, jack@suse.cz, dsterba@suse.com, mjguzik@gmail.com, dhowells@redhat.com, peterz@infradead.org Subject: [PATCH 0/6] Improve visibility of writeback Date: Wed, 20 Mar 2024 19:02:16 +0800 Message-Id: <20240320110222.6564-1-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgAHFZ2KRPplVj2CHQ--.18626S2 X-Coremail-Antispam: 1UD129KBjvJXoWxCw47ZF4DAr4xXw43Kw1UAwb_yoW5Cr43pF Z5Ar15Kr48A3WxCr93Ca42gr13t3y8ta47XrZrZrW2qrn0gr1DtF95Wa4Fyr15Jry3AFy3 JFsxZry8Kr4vqF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvvb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E 3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r xl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv 0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z2 80aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4IIrI8v 6xkF7I0E8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI 8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AK xVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI 8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E 87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73Uj IFyTuYvjxUIf-PUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Stat-Signature: bc6og9w3nfbnxzkpmygnq63jf6djuici X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C299018000E X-Rspam-User: X-HE-Tag: 1710900369-514651 X-HE-Meta: U2FsdGVkX1+tCj/XsoXvWuVpfYsjawcnx3ch2+gdu4w457+2FfSHcvc8NWHxbNMWvrA5kTHKzV8G7eznb0KtqJQcJeA1DdX9Rc7i+UGQhj2LQHdCKkreESVBQ06BZ/BI28TmTcp8TkONxM4Rpq9Msh7u94Rq+mORimZp61GC83amKLUNjt8aKTU10U4KrjsHxMs0w++J7sPLQcsUBLMh8vFndIvaVfmxFMqzGWjQw0bWOj5/F9MTrRuO0tPGw6DSqU9hIQBHXBwepNqPlEIM0bQU6vKmt3Ge4xNPOe6YbtWTw/908QIT8DD+8/qcsyzQagcO51Vfdeb+R0LKsIGKnwmbkiw7zx25+paVzaSoeofBHTkvbjqinS+uAph3/966mHE+R1OvnzbNdScVxhZT1FmYBI1spxJta0klW1qetODgnSx5aAJIz60ldEa9vNP3KPvLxXCvgAiN+Z4XI84iNuZYlsT/YEvEcCMNpe0Ke7BzBxE3Xe+77/Z+HGk93QCTPbC3OolgQqS/HUDP60nd6y9cXiObsgwc0re9s7Ml/7KlLQTYQ60OljfJAYmF43bHGthkulgzSxPfzgyQRa6INuswTL5xJ9IVOMbkBWvUTXZQAQ8jdf07oo2mr/WTW7u/5iu9W8dEJvRt4n4LP11TOikxkRCbBpiaFSELE7z8/DqVh5ajmvPZcJEGSHpVebSo9Q+0g43NibhDzHkhFIeqkU3ubnYQRO9EPxtK2OQHEgXLVHHZkOaZcoyTc5Ai8g8juqEiW8HZDRhNtH2FMq02R0RvHpMAfPQRUQPfj/usfpXOxzGdZ5sVKfhl5kSml5hs5FVQQ0lzmPzf+ItNWjEjaiQgIrDnew/a0XgV9EBr0nEod332rOwfy3NFGCQIBLN3+9sN89FeuL8YqFWRiAkN95nqJ+ly3R1Tx8cV8+m+TxxAG1SlU7gZh/f0oR2l1d48 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This series tries to improve visilibity of writeback. Patch 1 make /sys/kernel/debug/bdi/xxx/stats show writeback info of whole bdi instead of only writeback info in root cgroup. Patch 2 add a new debug file /sys/kernel/debug/bdi/xxx/wb_stats to show per wb writeback info. Patch 4 add wb_monitor.py to monitor basic writeback info of running system, more info could be added on demand. Rest patches are some random cleanups. More details can be found in respective patches. Thanks! Following domain hierarchy is tested: global domain (320G) / \ cgroup domain1(10G) cgroup domain2(10G) | | bdi wb1 wb2 /* all writeback info of bdi is successfully collected */ # cat /sys/kernel/debug/bdi/252:16/stats: BdiWriteback: 448 kB BdiReclaimable: 1303904 kB BdiDirtyThresh: 189914124 kB DirtyThresh: 195337564 kB BackgroundThresh: 32516508 kB BdiDirtied: 3591392 kB BdiWritten: 2287488 kB BdiWriteBandwidth: 322248 kBps b_dirty: 0 b_io: 0 b_more_io: 2 b_dirty_time: 0 bdi_list: 1 state: 1 /* per wb writeback info is collected */ # cat /sys/kernel/debug/bdi/252:16/wb_stats: cat wb_stats WbCgIno: 1 WbWriteback: 0 kB WbReclaimable: 0 kB WbDirtyThresh: 0 kB WbDirtied: 0 kB WbWritten: 0 kB WbWriteBandwidth: 102400 kBps b_dirty: 0 b_io: 0 b_more_io: 0 b_dirty_time: 0 state: 1 WbCgIno: 4284 WbWriteback: 448 kB WbReclaimable: 818944 kB WbDirtyThresh: 3096524 kB WbDirtied: 2266880 kB WbWritten: 1447936 kB WbWriteBandwidth: 214036 kBps b_dirty: 0 b_io: 0 b_more_io: 1 b_dirty_time: 0 state: 5 WbCgIno: 4325 WbWriteback: 224 kB WbReclaimable: 819392 kB WbDirtyThresh: 2920088 kB WbDirtied: 2551808 kB WbWritten: 1732416 kB WbWriteBandwidth: 201832 kBps b_dirty: 0 b_io: 0 b_more_io: 1 b_dirty_time: 0 state: 5 /* monitor writeback info */ # ./wb_monitor.py 252:16 -c writeback reclaimable dirtied written avg_bw 252:16_1 0 0 0 0 102400 252:16_4284 672 820064 9230368 8410304 685612 252:16_4325 896 819840 10491264 9671648 652348 252:16 1568 1639904 19721632 18081952 1440360 writeback reclaimable dirtied written avg_bw 252:16_1 0 0 0 0 102400 252:16_4284 672 820064 9230368 8410304 685612 252:16_4325 896 819840 10491264 9671648 652348 252:16 1568 1639904 19721632 18081952 1440360 ... Kemeng Shi (6): writeback: collect stats of all wb of bdi in bdi_debug_stats_show writeback: support retrieving per group debug writeback stats of bdi workqueue: remove unnecessary import and function in wq_monitor.py writeback: add wb_monitor.py script to monitor writeback info on bdi writeback: rename nr_reclaimable to nr_dirty in balance_dirty_pages writeback: remove unneeded GDTC_INIT_NO_WB include/linux/writeback.h | 1 + mm/backing-dev.c | 159 ++++++++++++++++++++++++++----- mm/page-writeback.c | 32 +++++-- tools/workqueue/wq_monitor.py | 9 +- tools/writeback/wb_monitor.py | 172 ++++++++++++++++++++++++++++++++++ 5 files changed, 334 insertions(+), 39 deletions(-) create mode 100644 tools/writeback/wb_monitor.py