Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3330540lqp; Tue, 26 Mar 2024 06:32:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPGSwOsmnllXoJeRS0nNaiWvZnfjZ8tWSc9AvnCj1DpZeQLmYA3SZlid/QPTJikRxBjEkIZtVhNGwc2368jSU26gJG2Lru0THrmjIFzg== X-Google-Smtp-Source: AGHT+IF7BH6KT0LnfSaeyouBmW4Sc5le+PkBlDO+F7/M9Ubv3AxSxKjwvA5xvnA+Gp+ZNNJsDIvI X-Received: by 2002:a17:902:7488:b0:1e0:acb1:7977 with SMTP id h8-20020a170902748800b001e0acb17977mr8407842pll.49.1711459937881; Tue, 26 Mar 2024 06:32:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711459937; cv=pass; d=google.com; s=arc-20160816; b=NhdtFBYjnCRF8HkGFTj5xMNY/xQopaLRuwIHrLxt9lvh5XV0pCYiZcj7trlt7x9GzR OXhgixFYTJLu1agsOuDYGEwjwJpf2WPqV6AHHzZUzhlJcX1qd8dtjKOujZTML1LoDjVU rBAEi9TxyChq5mxr98PeB6fZnO/1tTTtN271ipM8D1SbIJTEzolRh3UADGar7lIPLrND x60fB7hxumz+1yLVcletxFTUrSjrmIimzNwaGxF4hYdgfCpwpBnuUxIcFEdNaclNp2y8 mz8WuV6QpyAlQ86IDG7bFEAZv1b5vWlvlPGIY1IvPGmA4P+Tj3kEBZfbOvVSI/eU97bl PGqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=vMO7LLM6MrbANjUZqvLDjeOFbmyZJiQMvGeaV6oiH4o=; fh=UTltJTs+wAXkLdI2ZvhGWzZhEPCz4GS10C+f9LZR+Fc=; b=yf9/nVuUYKqjqiZlSn+sMA5BkaGmAyI411iTBEejN4gu4++GE1DPuM4vT9FH00irHp nYtpz+70xSy+U/slEFFhVUdBjIcuK5tXK1WotCd87Rfhb64m+nuHtaDX+bLGDptBGkNH WVo7+r2NO63SFdZOVxob6sKoGXY44wSl7NpOV+omOxVM6EBZMy1bala1lzu7nesxzHEg /NkVmG3VTmN6sRGxpdRkhI1sLzoOo3jde2q0KY2z2xeSV02Kp2fIH9pnNCKC6bf8hhSs MPefMVfqTUEenPpxIpor9j8mMWnCCp2YmteggggR2+eThZRKd2ZrQ4j1khHHX9mTWTp8 qYtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-119055-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119055-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l5-20020a170902f68500b001e024d34330si7525610plg.438.2024.03.26.06.32.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:32:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119055-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-119055-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119055-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B3228B23575 for ; Tue, 26 Mar 2024 13:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC8F374C0C; Tue, 26 Mar 2024 13:26:50 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC4BD6D1CE; Tue, 26 Mar 2024 13:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711459610; cv=none; b=k4rMgQ6S+2lVqRr1qkJvyXjouNFLwrAvckywaGeR6DZ7tjDOdGuNEwwJBIP4NzBnHakxQbf5nTsBWwuC+EYMYdDwdVUA1UJEUVGBHST26MppSnTmFiAvWOILyzIKi269clHKAn/oJWxhwS+lh332XOCiERTs0WOHJr/9ZKXaBSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711459610; c=relaxed/simple; bh=e4cTCvKLicPrP/BBzqMrTnQ/mc0bQqdRpDQFbZlR8hw=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=Jx+hrZ8NF/nIKDknqbTOsscu9/q1mAR8NjQYWJfQ1860A1Dkt7boeLbXUGfvN9x/st4aOxCQxmae5I2/IGF1jd++Q51fYhI7kuU3+b1MFSEYfUDXI5Ej19qZz7UYs/Ss0Ao2aTy99ePBsBFuiPV2AiNBrHRsotsUn7RLcENypL4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4V3rDX08KNz4f3m78; Tue, 26 Mar 2024 21:26:36 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 1DA2B1A06D7; Tue, 26 Mar 2024 21:26:44 +0800 (CST) Received: from [10.174.178.129] (unknown [10.174.178.129]) by APP3 (Coremail) with SMTP id _Ch0CgA3RJwSzQJmvaESIA--.44448S2; Tue, 26 Mar 2024 21:26:43 +0800 (CST) Subject: Re: [PATCH 2/6] writeback: support retrieving per group debug writeback stats of bdi To: Jan Kara Cc: akpm@linux-foundation.org, tj@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, willy@infradead.org, bfoster@redhat.com, dsterba@suse.com, mjguzik@gmail.com, dhowells@redhat.com, peterz@infradead.org References: <20240320110222.6564-1-shikemeng@huaweicloud.com> <20240320110222.6564-3-shikemeng@huaweicloud.com> <20240326122421.dofl35cdtgaojt26@quack3> From: Kemeng Shi Message-ID: <206c3800-01ec-2d3b-fe89-cbb1b36158a3@huaweicloud.com> Date: Tue, 26 Mar 2024 21:26:42 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240326122421.dofl35cdtgaojt26@quack3> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit X-CM-TRANSID:_Ch0CgA3RJwSzQJmvaESIA--.44448S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ZF1ftFW3Zr45CFWfXr1xuFg_yoW8GF4xpF WkAayYkF4jyrWqkr47Za4q9FW7t3y8GrW2q3yfGay3Xrn29rySgFyfur97uF1fCFyfGry5 AFsIvr97W3WkCrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7I2V7IY0VAS 07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c 02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_ GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7 CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE 14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf 9x07UGYL9UUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ on 3/26/2024 8:24 PM, Jan Kara wrote: > On Wed 20-03-24 19:02:18, Kemeng Shi wrote: >> Add /sys/kernel/debug/bdi/xxx/wb_stats to show per group writeback stats >> of bdi. >> >> Signed-off-by: Kemeng Shi > > ... > >> +unsigned long wb_calc_cg_thresh(struct bdi_writeback *wb) >> +{ >> + struct dirty_throttle_control gdtc = { GDTC_INIT_NO_WB }; >> + struct dirty_throttle_control mdtc = { MDTC_INIT(wb, &gdtc) }; >> + unsigned long filepages, headroom, writeback; >> + >> + gdtc.avail = global_dirtyable_memory(); >> + gdtc.dirty = global_node_page_state(NR_FILE_DIRTY) + >> + global_node_page_state(NR_WRITEBACK); >> + >> + mem_cgroup_wb_stats(wb, &filepages, &headroom, >> + &mdtc.dirty, &writeback); >> + mdtc.dirty += writeback; >> + mdtc_calc_avail(&mdtc, filepages, headroom); >> + domain_dirty_limits(&mdtc); >> + >> + return __wb_calc_thresh(&mdtc, mdtc.thresh); >> +} > > I kind of wish we didn't replicate this logic from balance_dirty_pages() > and wb_over_bg_thresh() into yet another place. But the refactoring would > be kind of difficult. So OK. Thanks for review the code. I have considered about this. It's difficult and will introduce a lot change to non-debug code which make this series uneasy to review. I will submit another patch for refactoring if I could find a way to clean the code. Kemeng > > Honza >