From patchwork Mon Apr 29 03:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13646248 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 33A88C4345F for ; Mon, 29 Apr 2024 03:47:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CFA26B0096; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 752D26B0098; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E2616B0095; Sun, 28 Apr 2024 23:47:55 -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 201EA6B007B for ; Sun, 28 Apr 2024 23:47:55 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 93D6A4177A for ; Mon, 29 Apr 2024 03:47:54 +0000 (UTC) X-FDA: 82061185668.22.2C84D1C Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by imf29.hostedemail.com (Postfix) with ESMTP id 5298012000D for ; Mon, 29 Apr 2024 03:47:50 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.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=1714362473; 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=rO5LDF5AfoSXhOyoW81F+0NQZkj1byH1zp8ZmzAyq0c=; b=BqlByP10hrd211jz2HxTGkOh7v1S3zMdsqNtWoI3kGepaFHgJ39ATeDVGEbjXrDW5uxYQp JgW4cWL170cT6GHQG8DlOZaswl65KuQat2D2sFQcGjv9fPn+3EwlsDVqN52rg65ar2A2Pc 8jBmCAzm1kYJvhSsBVhV4ETKqdRG5a8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of shikemeng@huaweicloud.com designates 45.249.212.56 as permitted sender) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714362473; a=rsa-sha256; cv=none; b=xWJGsT67E0XkZyJkT6yeHZTn445y6LgmOFFyla52iXP07LIEjQLf9WZtORzN2YYA0JytOd lQL3nG+n5d7acS0o8Hrau1JMIRj9KDbghp7f3taWkMoNqCGpsj3KJ3FIcXYF80IoWiEKYO uEqg5GNvaqbfCnbugDfEwwImmRAI688= Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VSTmp046lz4f3jHZ for ; Mon, 29 Apr 2024 11:47:38 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id CA5F11A08FC for ; Mon, 29 Apr 2024 11:47:45 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.6]) by APP1 (Coremail) with SMTP id cCh0CgA3UwxgGC9m24__LA--.38879S2; Mon, 29 Apr 2024 11:47:45 +0800 (CST) From: Kemeng Shi To: willy@infradead.org, akpm@linux-foundation.org, jack@suse.cz, tj@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 00/10] Add helper functions to remove repeated code and Date: Mon, 29 Apr 2024 11:47:28 +0800 Message-Id: <20240429034738.138609-1-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CM-TRANSID: cCh0CgA3UwxgGC9m24__LA--.38879S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw18WF1rGF4kJF47AF1rCrg_yoW8tFW7pF Z3Kr1aqr1UJ3W3Ar9xCay29ryS9397AF45t3sxXw4SvF43Cry2gFy2vFyFkay2yFy3Gry5 ZFs8t34xGr1qkaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUgKb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCj c4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4 CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1x MIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJV Cq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBI daVFxhVjvjDU0xZFpf9x07UWE__UUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-Rspamd-Queue-Id: 5298012000D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: id6s5cdesk4r8gip3z58ap54f99rcfgw X-HE-Tag: 1714362470-279374 X-HE-Meta: U2FsdGVkX1+hfGBnI5OdEhts3Jvnb4euVPIMAqAwgnwaFxZtPtymk3d9O7EnsJ256RAQ4MLd5qLxUZ/0mGHQnCrNLiit99kVqULAtiAc6kyiMX456Vp8aeiNgK5RxLnvrQfNvM1ecVKbBVjornKvEejRtK2P8MiajxJHG0YJL90vTcjI0w6dXP5SqAvT5rjLljITg0l/Bx1Rj6bB7cyLL3GQ8I4219mzY8/jngr7qJGeq5U6KkpAzHK4TRd4Ep6lxwcbo3IITbEUpmUGuJdOFmIY+jbmuzaSOCJhl5n8wqnqYoREM5o5X4YsX1RKDrcL2fmYyEAXltU0JnAwUTgw0k1PhRLYskRQY+2wGypJUnl9JBCrwJetWg2AMwsmZge69qAmkqj1RffHM/2E5XH3BE8S6ZtuyhfQqdlpSxf49C+J8yrQKc659jdbHxePFQcjujV1Ap4moAEQZfGHuLNjQspLNZwMla64C/Orrf/fwHeoEC1oMJti+HvFuhkTj55Xc9YKIXoJcRfRd5tEkV7LZM+TRa+n+14r0A6aQF/soFp5AxsfKX4lHvkSzJnKc/hcWXuQHIDjDoD1QpXC2Z1+lCZphxl6N6winXgmjpzov9Yu5cnuf9iI+C6rwEJNgcQ0TpdflhQxNphAeqq+6OL2ewzGqdIKx6rEAl2ceqt3VQa944rJe7WPPqEGDD2iPnJCMj/SU5Z2dgPkdyLzq/mImMTOmEp/zPGhtaRWOZoL2ieqDfOApre9+FT/t+4pcZwNb2gmHk4Yaz4XqmaxhzgMwsZackfVsA555v4xhxM058ZTugwg4JoaZ8gnlcpPTcHiKu+DkkRAQYVGRVV2Q9jESYmEOZmQ26a6xXZL/EiNJZM= 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 add a lot of helpers to remove repeated code between domain and wb; dirty limit and dirty background; global domain and wb domain. The helpers also improve readability. More details can be found on respective patches. Thanks. A simple domain hierarchy is tested: global domain (> 20G) | cgroup domain1(10G) | wb1 | fio Test steps: /* make it easy to observe */ echo 300000 > /proc/sys/vm/dirty_expire_centisecs echo 3000 > /proc/sys/vm/dirty_writeback_centisecs /* create cgroup domain */ cd /sys/fs/cgroup echo "+memory +io" > cgroup.subtree_control mkdir group1 cd group1 echo 10G > memory.high echo 10G > memory.max echo $$ > cgroup.procs mkfs.ext4 -F /dev/vdb mount /dev/vdb /bdi1/ /* run fio to generate dirty pages */ fio -name test -filename=/bdi1/file -size=xxx -ioengine=libaio -bs=4K \ -iodepth=1 -rw=write -direct=0 --time_based -runtime=600 -invalidate=0 When fio size is 1.5G, the wb is in freerun state and dirty pages is written back when dirty inode is expired after 30 seconds. When fio size is 2G, the dirty pages keep being written back. When fio size is 3G, the dirty pages keep being written back and bandwidth of fio is reduce to 0 occasionally. It's more easy to observe the dirty limitation by set /proc/sys/vm/dirty_ratio to a higher value, and set /proc/sys/vm/dirty_ratio back to 20 when 3G pages are dirtied. Kemeng Shi (10): writeback: factor out wb_bg_dirty_limits to remove repeated code writeback: add general function domain_dirty_avail to calculate dirty and avail of domain writeback: factor out domain_over_bg_thresh to remove repeated code writeback use [global/wb]_domain_dirty_avail helper in cgwb_calc_thresh writeback: call domain_dirty_avail in balance_dirty_pages writeback: Factor out code of freerun to remove repeated code writeback: factor out wb_dirty_freerun to remove more repeated freerun code writeback: factor out balance_domain_limits to remove repeated code writeback: factor out wb_dirty_exceeded to remove repeated code writeback: factor out balance_wb_limits to remove repeated code mm/page-writeback.c | 324 ++++++++++++++++++++++++-------------------- 1 file changed, 176 insertions(+), 148 deletions(-)