Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp150498lqh; Wed, 27 Mar 2024 18:50:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUf1mSBKCXS6Uk+9UZYNZMyGtH5AWTyT53mP757x+Pz19tVsinpAYBfxeutM4bPY78gnxFH6wTnWoRD4JVROrmNZuDJ3++vhJpeqtrdTg== X-Google-Smtp-Source: AGHT+IFIFq+9gtSj4faJJPRffplwGS9rDDly1f5jC0mQCrOeAWl/QgbpbZXGPijpD77fomIZ3XdP X-Received: by 2002:a17:907:7802:b0:a46:6faa:2b8 with SMTP id la2-20020a170907780200b00a466faa02b8mr795579ejc.68.1711590632861; Wed, 27 Mar 2024 18:50:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711590632; cv=pass; d=google.com; s=arc-20160816; b=Bu2Xeg/nDZLYkGt2OfVSpC42qMdNUYQc2gGpvdV1ecyuSifqnRlM+WGjdB7laSU4+7 Z4PpHaq4sda7qagorWNNy1Tw8qOxKytn+aUKO4ySLBmSWopJhsO8VoYMZhXcRel/JBdF VNM/ZaFxi8np1RdMc3umf0s/mR3KhxKYPKeo0wzG7aoTH6R6lWrRDTYHMz0Wve6htVu2 vZ820i/ajaMSfG4aCaKLRc0H1bF2VaJpPaPIWsgIqE+WSzj2HQyyaAvp8Md7Fk/i7HuQ 9Lo0NDeoWkep707RqPE66O7UONJ60BjVxxngvAHh1aJ4KDLRZHfp7Bc6eEEEVWp47Mtf KwlA== 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=B0dJXnakOQ1Y4+TIfljD6zvS1hc0HcYDj0CNhhMHwHs=; fh=vIB8YdJ6bIn1eeNirvISNI8zXGfGcAXYwy7zRX7aYq8=; b=lCDBeM8ncTt7/5jUhptOhGr+9tZqltb9Mz9lkoWUS9wSUolHxWBSIqvZtU616QTWt2 MwaJf112QmERdt8ineH0WfGBuN9KMz2xLRkifly6WYeyfV7g79uiEGkMLOJ0U81XXWLB dwg0MkQNuZELCVVbwgfP6f6dqVqXCNOVWyquPhMPDObgEVrGIgsPJmGY80fCwWBTP8Ev U5p4eL54mmn5ocHiqk9Fhl74STg3Hut4ng624b39iE7cpBF8aE2QJ2BFtojtMRnXa/q1 rWZIHYMjJTLFEpc+U44YZwLquij8ak4ziF4Pbj3C/6yC1o//QrpJ6Q64FY5VAp8TT/u/ 8DCQ==; 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-122305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122305-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gy14-20020a170906f24e00b00a47487dfcacsi173008ejb.445.2024.03.27.18.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 18:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-122305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122305-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9645D1F2C1CD for ; Thu, 28 Mar 2024 01:50:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0C24249E5; Thu, 28 Mar 2024 01:50:15 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 611A91804A; Thu, 28 Mar 2024 01:50:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711590615; cv=none; b=df4FsJPbbA27RIuvD0gCAkRfk3MpqzZD/tmGH2vTyCWdVhPmtp1sGlVYU8yYqNUahG28qfwgyItikn2BYbIx0zw9FlDair8IjRDPPRbGPT8rXghmDtMkpFGT871PfzPTA2gWApqOuzoVGV/sa9rVIlP3eOMnuleB/fVpoeztUUo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711590615; c=relaxed/simple; bh=bCc3hgIaTxZx0x4kXtgyejnC6eC3hJer74tT/KCfGyI=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=E+RTWfGARPAKKMEJfwybiZdBJw9FX9l1UBTzgXXvQ5ToJlQEZnDiI2vXY8FwBsgwuckEIhZG78yfQLQMfGp6fxPabjSTIYUK6k58HK3NvmSJ1zXwrBNs7cy1UumVCajfm0hr1Ao3d/B3cBoHp3W6C6YCxzRrokqoaQ719RxBU6s= 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.56 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4V4mgl2xxwz4f3jY5; Thu, 28 Mar 2024 09:49:55 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A4A041A0BA6; Thu, 28 Mar 2024 09:50:01 +0800 (CST) Received: from [10.174.178.129] (unknown [10.174.178.129]) by APP4 (Coremail) with SMTP id gCh0CgDnOWzHzARmkrC_IQ--.19172S2; Thu, 28 Mar 2024 09:50:01 +0800 (CST) Subject: Re: [PATCH 6/6] writeback: remove unneeded GDTC_INIT_NO_WB To: Jan Kara Cc: Tejun Heo , akpm@linux-foundation.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-7-shikemeng@huaweicloud.com> <20240327093309.ejuzjus2zcixb4qt@quack3> From: Kemeng Shi Message-ID: Date: Thu, 28 Mar 2024 09:49:59 +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: <20240327093309.ejuzjus2zcixb4qt@quack3> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit X-CM-TRANSID:gCh0CgDnOWzHzARmkrC_IQ--.19172S2 X-Coremail-Antispam: 1UD129KBjvJXoWxCFyUGry8Jry8Cw1kurW8tFb_yoW5trW3pF W3Wa1DK3W5Ja4SvrnxKwn7X3Z8KrZ7try7X3s0kw4DZrs5Grn7Krn2qa1ruF12yr1x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rote: >>> Hello, >>> >>> On Wed, Mar 20, 2024 at 07:02:22PM +0800, Kemeng Shi wrote: >>>> We never use gdtc->dom set with GDTC_INIT_NO_WB, just remove unneeded >>>> GDTC_INIT_NO_WB >>>> >>>> Signed-off-by: Kemeng Shi >>> ... >>>> void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty) >>>> { >>>> - struct dirty_throttle_control gdtc = { GDTC_INIT_NO_WB }; >>>> + struct dirty_throttle_control gdtc = { }; >>> >>> Even if it's currently not referenced, wouldn't it still be better to always >>> guarantee that a dtc's dom is always initialized? I'm not sure what we get >>> by removing this. >> As we explicitly use GDTC_INIT_NO_WB to set global_wb_domain before >> calculating dirty limit with domain_dirty_limits, I intuitively think the >> dirty limit calculation in domain_dirty_limits is related to >> global_wb_domain when CONFIG_WRITEBACK_CGROUP is enabled while the truth >> is not. So this is a little confusing to me. > Hi Jan, > I'm not sure I understand your confusion. domain_dirty_limits() calculates > the dirty limit (and background dirty limit) for the dirty_throttle_control > passed in. If you pass dtc initialized with GDTC_INIT[_NO_WB], it will > compute global dirty limits. If the dtc passed in is initialized with > MDTC_INIT() it will compute cgroup specific dirty limits. No doubt about this. > > Now because domain_dirty_limits() does not scale the limits based on each > device throughput - that is done only later in __wb_calc_thresh() to avoid> relatively expensive computations when we don't need them - and also > because the effective dirty limit (dtc->dom->dirty_limit) is not updated by > domain_dirty_limits(), domain_dirty_limits() does not need dtc->dom at all. Acutally, here is the thing confusing me. For wb_calc_thresh, we always pass dtc initialized with a wb (GDTC_INIT(wb) or MDTC_INIT(wb,..). The dtc initialized with _NO_WB is only passed to domain_dirty_limits. However, The dom initialized by _NO_WB for domain_dirty_limits is not needed at all. > But that is a technical detail of implementation and I don't want this > technical detail to be relied on by even more code. Yes, I agree with this. So I wonder if it's acceptable to simply define GDTC_INIT_NO_WB to empty for now instead of remove defination of GDTC_INIT_NO_WB. When implementation of domain_dirty_limits() or any other low level function in future using GDTC_INIT(_NO_WB) changes to need dtc->domain, we re-define GDTC_INIT_NO_WB to proper value. As this only looks confusing to me. I will drop this one in next version if you still prefer to keep definatino of GDTC_INIT_NO_WB in the old way. Thanks, Kemeng > > What might have confused you is that GDTC_INIT_NO_WB is defined to be empty > when CONFIG_CGROUP_WRITEBACK is disabled. But this is only because in that > case dtc_dom() function unconditionally returns global_wb_domain so we > don't bother with initializing (or even having) the 'dom' field anywhere. > > Now I agree this whole code is substantially confusing and complex and it > would all deserve some serious thought how to make it more readable. But > even after thinking about it again I don't think removing GDTC_INIT_NO_WB is > the right way to go. > > Honza >