From patchwork Sun Oct 6 15:28:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Yizhou X-Patchwork-Id: 13823775 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5441482EF for ; Sun, 6 Oct 2024 14:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728226382; cv=none; b=LW5eNKnCKVQaOHqUgYYOcd7navD2H7MCdgJSeweB4a59yIIj8PAgvNNAt9aQKYu6SENbzut4naNFyWCpIm26z7FqDzx2UUSaL/a3uF4G4hDNRmNtQTLNHWOGFlISP+kZXNxRo1IdHF7c38J/RwjUg/W0pHqTg/JSyf/zFk1Rq+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728226382; c=relaxed/simple; bh=aUA1bM8P1Ew8vQnt7B9NnQGncWdEinSrEJ/F9sbP0Yw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Doukh1GnWBe8er+tCvB8bam+gJCxbKOUcLSZm1kqej/9R3yoWk2vQcFT+aqF/ml39ChW74t9W8aQsjXagBMLZjyF5fmaQfe44+oVxHZXcYF9CJdDXvb7Mo5swDeV+OMZ6UKupR3/22u2VBtqYbbX0Oyeem821CMVHz2MxEk6PqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=UqcEU7c8; arc=none smtp.client-ip=209.85.215.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="UqcEU7c8" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7db90a28cf6so3065061a12.0 for ; Sun, 06 Oct 2024 07:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1728226380; x=1728831180; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2N3sStJpxaR2HR+abJXgKtrpDLoMQudskN/sLQC1NOU=; b=UqcEU7c8PNl2etyuIiEZvkWioZe2OicNj67J8AhtdKEgQqqysFRaezha7Iw06uT/pY OdTZCwGNB5PvzuS9cCTAwlsZBqYlymlYdZto4Tmc5yoyQvsGF6bVe9QpOjXCiF+hvMgR E+VCn5MRKxrRIDmGVSy6NRt33iE8wcnlfxcybIEi3050FsoYXdvDPZp8+4Tkv7HSkw69 w/1gi7Lm4ACq8+9/h4SbaEsit8iNPfORdxoe9byfx7Qk2eFaX+q9d6ht1tuH84TN9eIe h2N9qNYyWwEVkaTsH0rr9W3stO+xP4x/toCHznr5izoX0i1wGNPHvbO5ULO89cDr7qgu fMoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728226380; x=1728831180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2N3sStJpxaR2HR+abJXgKtrpDLoMQudskN/sLQC1NOU=; b=Qm7cUMdUDKJTSv/DzToeGnY9bML+Nh5MsXaE+GlYWmlS7vUcr1XKUmpack4moi0uEJ dbBH5/GUE3R5kGuJ24vbRX/Y/B4Vgy2dY5gJRWQBzA3r2Y14JALRUXU+Z0ng5aQw9BIW WmVtjFFe/z+M15+nP+CYnxwtyg30G+w1CUdHi9HFixCS3N2TN+3z62YjP9B8x50NRBbr 5HYdF1xPHpPotZaU4g5daimJrdE9vyeq9gQul114OkFlDAovzwsZ+RVewLhOvMbzvEe3 bbeSd71okQv5JH5D088XrhueaF5qKZ3GCv2z8OFI3L4fHYxAh9DbE12LuPKcnNDJn8W6 9Edw== X-Forwarded-Encrypted: i=1; AJvYcCUsYJZzxwqaBGPiON3MjHIL5ajRUFVY6JZg3t5PLPQtLyHc0/j5hBA5ULnQfCURMPL4G/3dhqzuu00=@vger.kernel.org X-Gm-Message-State: AOJu0YxTwCYg6gkEjqHlsFUoZBhBmf44DSYClZvOBegQWGQiZ0dDUzoF JyOKfqnQIJZeyTooZcRBq9j1+OnZQol4pqR4e8gwIVP6qVoiQcgsZFMUEeP2JLs= X-Google-Smtp-Source: AGHT+IHG4IQr7deYQUJRIYz9fhcCuV66BnPCOFrXxZCcjoVgw9zfF27tSDdPFaL2+eQyuT6EmIQ+7w== X-Received: by 2002:a17:90a:fb8b:b0:2e0:7580:6853 with SMTP id 98e67ed59e1d1-2e1e5dba9e2mr12443142a91.17.1728226380265; Sun, 06 Oct 2024 07:53:00 -0700 (PDT) Received: from localhost.localdomain ([143.92.64.17]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e8664bfasm5213680a91.44.2024.10.06.07.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 07:52:59 -0700 (PDT) From: Tang Yizhou X-Google-Original-From: Tang Yizhou To: jack@suse.cz, hch@infradead.org, willy@infradead.org, akpm@linux-foundation.org, chandan.babu@oracle.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, Tang Yizhou Subject: [PATCH v2 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to BW_DIRTYLIMIT_INTERVAL Date: Sun, 6 Oct 2024 23:28:47 +0800 Message-Id: <20241006152849.247152-2-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241006152849.247152-1-yizhou.tang@shopee.com> References: <20241006152849.247152-1-yizhou.tang@shopee.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tang Yizhou The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit(). Rename BANDWIDTH_INTERVAL to BW_DIRTYLIMIT_INTERVAL to make things clear. This patche doesn't introduce any behavioral changes. v2: Rename UPDATE_INTERVAL to BW_DIRTYLIMIT_INTERVAL. Signed-off-by: Tang Yizhou --- mm/page-writeback.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index fcd4c1439cb9..3af7bc078dc0 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -54,9 +54,9 @@ #define DIRTY_POLL_THRESH (128 >> (PAGE_SHIFT - 10)) /* - * Estimate write bandwidth at 200ms intervals. + * Estimate write bandwidth or update dirty limit at 200ms intervals. */ -#define BANDWIDTH_INTERVAL max(HZ/5, 1) +#define BW_DIRTYLIMIT_INTERVAL max(HZ/5, 1) #define RATELIMIT_CALC_SHIFT 10 @@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc, /* * check locklessly first to optimize away locking for the most time */ - if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) + if (time_before(now, dom->dirty_limit_tstamp + BW_DIRTYLIMIT_INTERVAL)) return; spin_lock(&dom->lock); - if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) { + if (time_after_eq(now, dom->dirty_limit_tstamp + BW_DIRTYLIMIT_INTERVAL)) { update_dirty_limit(dtc); dom->dirty_limit_tstamp = now; } @@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb, wb->dirty_exceeded = gdtc->dirty_exceeded || (mdtc && mdtc->dirty_exceeded); if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) + - BANDWIDTH_INTERVAL)) + BW_DIRTYLIMIT_INTERVAL)) __wb_update_bandwidth(gdtc, mdtc, true); /* throttle according to the chosen dtc */ @@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) * writeback bandwidth is updated once in a while. */ if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) + - BANDWIDTH_INTERVAL)) + BW_DIRTYLIMIT_INTERVAL)) wb_update_bandwidth(wb); return ret; } @@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb) atomic_dec(&wb->writeback_inodes); /* * Make sure estimate of writeback throughput gets updated after - * writeback completed. We delay the update by BANDWIDTH_INTERVAL + * writeback completed. We delay the update by BW_DIRTYLIMIT_INTERVAL * (which is the interval other bandwidth updates use for batching) so * that if multiple inodes end writeback at a similar time, they get * batched into one bandwidth update. */ spin_lock_irqsave(&wb->work_lock, flags); if (test_bit(WB_registered, &wb->state)) - queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL); + queue_delayed_work(bdi_wq, &wb->bw_dwork, BW_DIRTYLIMIT_INTERVAL); spin_unlock_irqrestore(&wb->work_lock, flags); } From patchwork Sun Oct 6 15:28:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Yizhou X-Patchwork-Id: 13823776 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FE9B1482F2 for ; Sun, 6 Oct 2024 14:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728226385; cv=none; b=WkxQHiPiG+g75LryxNxBzQSrq2/EI654gg4Yt9aAHh7YbzHizrFFes+IEIH8p1ZlDpLJZElpcni8CTnqHrc9c/ttxJmxiYD3K3tEwvzqD1UoAhxwcOIs27IED9SU7LIdv993HfpOsTO5hTeUFtIy89v9gXK5mwQDCRNyw8uhXG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728226385; c=relaxed/simple; bh=rhJ9GRZNgwHY1raVKmWuJN9qtyI0iNeH7MHZzGrpBag=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nc6ksvz9SaZxuLG4kc8J4aM5dhDILvqH+CMXSK2wrWfFX8BPA+3KtwVLrn0M8qGsewyYVSqDpgUmPJDLb86Aip9LtjdQ2jdP66zQLETR8A2jM2wSGQHq63Qf13lVMtqDQ91T4uYhQTbeLSiU/Ln42ApjDp1xobW2F1147XDJLtA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=P4kxfRrn; arc=none smtp.client-ip=209.85.216.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="P4kxfRrn" Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2e0af6e5da9so2703149a91.2 for ; Sun, 06 Oct 2024 07:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1728226383; x=1728831183; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8AqnyP+Byv1dd6vDoQ+Ar0AhPFXyUFcqkrKiBNXDFDI=; b=P4kxfRrnfOTUhLfMRH36lD5Mqw+3Xxj3VHD7XPNLOPXVjsu6G29ugkz5H4tpAugc+n Xtx/suJum5v5aCre6gIJADij2Yco+SwdNJUSDrDwmRUV7VAn3hhY+UhG9cqAPYwQ1M+w 6z/JLlfkQ62Eb/TA16NpzPexB7SXb9xSWx8+NpwKY3uOPKzhFpIlzh0oTj1cjAumRKLQ c8T05yj3l0d0e+OQjqhfG71sWqpWMCaQgj2qD4aFTQ1cVkoiPhOwJSyHszsFj0xaZLvJ BZJ8+WXbk7UPP3YKlcIwYcQZuXl67tGeN8LLZVSRS4EtQMsoiwT7cj8KBD4TCAL/ffVF Rw8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728226383; x=1728831183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8AqnyP+Byv1dd6vDoQ+Ar0AhPFXyUFcqkrKiBNXDFDI=; b=YEX7/liw3YtY7j37aats6Ye9U2BvINCKhz5o2k17K7XLO6Ik0RBPUnkkHLOWGjhyOj F11piFTefBe3FAYgMTRgq2ygVusi9JkD5Kn8boybm/l+YkApepgl2bg05X8zGKN+UIZg zLoXr83FcFkGpu4gDGm73Up8ONPYY2ToxG5YCyy9Jn5iVyVolXXrAjnfon6CWHuDSRaw l6j7RtOl/+q8Tz0+zZYq23/dAVIVDbe8YgSeexxrUWj7gOSsPyNmr+7mQU0+pr9AQ7jh +QLitgYcH/JE2w3t3UB1OqrhLfCj7JwXBcS9gcMS56CGiAwZNNM6rlBwCDx7bNEGdR1E gGyA== X-Forwarded-Encrypted: i=1; AJvYcCUmXoQ4cHBchoGcvCY7t6AWgoe8CvaQUos83+U2MhmeX8i+ncd/d0RDldDtb/Ea8qiQBKD9owHETvM=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6O5l/Y9UT5KV87GcGiOrjprUNWyjJzhSnxtpqoQtv/Sxk9/Ag geibFAVULdSLlg0Hmom8y/XdWj/34qdW92W+42IjX7wkVYdK8V2PMa7iq1NnQek= X-Google-Smtp-Source: AGHT+IGPeVAO5tVDuO+R32h3LCBclCg7gEXpFP9t2p1QktdHAai9ZNmvTFB36rtLf2nnkg375yrefw== X-Received: by 2002:a17:90b:4f87:b0:2d8:8430:8a91 with SMTP id 98e67ed59e1d1-2e1e6221b1dmr11933090a91.10.1728226383035; Sun, 06 Oct 2024 07:53:03 -0700 (PDT) Received: from localhost.localdomain ([143.92.64.17]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e8664bfasm5213680a91.44.2024.10.06.07.53.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 07:53:02 -0700 (PDT) From: Tang Yizhou X-Google-Original-From: Tang Yizhou To: jack@suse.cz, hch@infradead.org, willy@infradead.org, akpm@linux-foundation.org, chandan.babu@oracle.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, Tang Yizhou Subject: [PATCH v2 2/3] mm/page-writeback.c: Fix comment of wb_domain_writeout_add() Date: Sun, 6 Oct 2024 23:28:48 +0800 Message-Id: <20241006152849.247152-3-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241006152849.247152-1-yizhou.tang@shopee.com> References: <20241006152849.247152-1-yizhou.tang@shopee.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tang Yizhou __bdi_writeout_inc() has undergone multiple renamings, but the comment within the function body have not been updated accordingly. Update it to reflect the latest wb_domain_writeout_add(). Signed-off-by: Tang Yizhou Reviewed-by: Jan Kara --- mm/page-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 3af7bc078dc0..68e48749c947 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -586,7 +586,7 @@ static void wb_domain_writeout_add(struct wb_domain *dom, /* First event after period switching was turned off? */ if (unlikely(!dom->period_time)) { /* - * We can race with other __bdi_writeout_inc calls here but + * We can race with other wb_domain_writeout_add calls here but * it does not cause any harm since the resulting time when * timer will fire and what is in writeout_period_time will be * roughly the same. From patchwork Sun Oct 6 15:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tang Yizhou X-Patchwork-Id: 13823777 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7284C14EC5E for ; Sun, 6 Oct 2024 14:53:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728226388; cv=none; b=l1nEY8rQrYzbzmqez+tA3YYvXneLx/VO7xl8av4stOByQduMU3dzhMT8+1xvyNY25N/gRWvYt86PFgg/lF52sStEc/b51AG32MnjOdWT+UEi5X6s05iZZPPRurhhRuw8DSpYRF6/xzfklNms+FgSP1j9Nv3ArcKcqLaLkWLAvUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728226388; c=relaxed/simple; bh=f7R704RsWlDrxzSooYYoOU0A7FIBYe24AoPYxQ5cGvw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pqc+YK1fX4YVl6ED39QFMPaGJtIBl55PXsS1UYtCt7HAi35lqMXLq1kK/Q/fYhLDwxCo/dYW0skRzCPLwp6GJw4mIWG9dYLW1eIlKMsoe654pBHlmTVji5EELlI61fLycLDBNjuKDE1Byd+7stSfGBF0EfdiiRUTv6GUAo/36TE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com; spf=pass smtp.mailfrom=shopee.com; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b=dz0oBZh3; arc=none smtp.client-ip=209.85.216.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=shopee.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shopee.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shopee.com header.i=@shopee.com header.b="dz0oBZh3" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2e199b1d157so2634349a91.2 for ; Sun, 06 Oct 2024 07:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopee.com; s=shopee.com; t=1728226387; x=1728831187; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9eAPrPoMERAiWqG8615Bek5ETZFlvIxFExngJIu2ukc=; b=dz0oBZh3VOLaKZ12KfCkGrlZggkZ3vcII6FAEBsXBIYSEEITBfr76HZYxbB+HfT5P9 51GoHOG77vMrJrzvBgUqSXKjc7xWKjj9EVoqvvg06lRH1yZPe6ZQ3PTl6+f4HN6hw4mY jM8YQfwChEk0g+ijVHHKRzyVO+euzqUZEEDf1rOe72oy+coMebybmlGOJNGNMaX0sfzZ dqd/3PcYu1Nds1WTHfCz3h9dO1pYJnkslCslRafLw63mNie/kzcjPAJkSsswwSxCHdYH 8m2Rfgj81j5xSo95DNldOZ491AAJyFkdroJvt9o4fIitNbYuvIBjM3Eyp0k3Cs9gC5hp pvuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728226387; x=1728831187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9eAPrPoMERAiWqG8615Bek5ETZFlvIxFExngJIu2ukc=; b=A7MoiDBzNSBeZysswv7TKfrU+Rc424eZKEM/yGZCy7E2YsYT6AG6lRgD4Pj4mU2hQW gkyQSolQXvuZsKW3+McciUWzIH3P+8aIJWqA7IlXh1ktMRNwOrlCbSCXOlRtQX3UTT+l 3QL09BBhyRL7LsD5wkqTLpN7Cjz7Xg1mP14FdcLFpgqK68EE3Ugfja+X4xqQtf2dec3X DY3sjP1dqyXc7QuH9vz/kI15FXcJ91lymP8fHVfqqZj7anY4K+K349CysdmDBl9AgusM FCRIYBP223znOwkBoCl/sOFev4+xe0OjvJrIdzpPW8fiuuD8EvKMaYeQWtEAsWfPh5Sq eoWw== X-Forwarded-Encrypted: i=1; AJvYcCXetPUtMa08Hleg9vC7tPCU2hmM2uQhwKu4p+4bct4FmYc8EHWXYA6CaJsYLwFBcxBV3PyzgPxz73A=@vger.kernel.org X-Gm-Message-State: AOJu0YxxHlV4E48FxvGIfe/TYpsR2NeQpsAR4IlGAaMg2sEsz4FTKwfc HippuF7BecM3fXZwJM8kT1og/XOrp4zbsbnYk4wwKU4byrkM78AG4EL5RDoWzOs= X-Google-Smtp-Source: AGHT+IGZxFAwhuS3OVDNQNCnjWK72kn4p7aawm+WgQnlBR5xxHp0OCCw7G+Tdm2ecDi8+9pF4eZ5cg== X-Received: by 2002:a17:90b:11c9:b0:2e0:ad69:1e08 with SMTP id 98e67ed59e1d1-2e1e6229186mr10941867a91.16.1728226386789; Sun, 06 Oct 2024 07:53:06 -0700 (PDT) Received: from localhost.localdomain ([143.92.64.17]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e8664bfasm5213680a91.44.2024.10.06.07.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 07:53:06 -0700 (PDT) From: Tang Yizhou X-Google-Original-From: Tang Yizhou To: jack@suse.cz, hch@infradead.org, willy@infradead.org, akpm@linux-foundation.org, chandan.babu@oracle.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, Tang Yizhou Subject: [PATCH v2 3/3] xfs: Let the max iomap length be consistent with the writeback code Date: Sun, 6 Oct 2024 23:28:49 +0800 Message-Id: <20241006152849.247152-4-yizhou.tang@shopee.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241006152849.247152-1-yizhou.tang@shopee.com> References: <20241006152849.247152-1-yizhou.tang@shopee.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tang Yizhou Since commit 1a12d8bd7b29 ("writeback: scale IO chunk size up to half device bandwidth"), macro MAX_WRITEBACK_PAGES has been removed from the writeback path. Therefore, the MAX_WRITEBACK_PAGES comments in xfs_direct_write_iomap_begin() and xfs_buffered_write_iomap_begin() appear outdated. In addition, Christoph mentioned that the xfs iomap process should be similar to writeback, so xfs_max_map_length() was written following the logic of writeback_chunk_size(). v2: Thanks for Christoph's advice. Resync with the writeback code. Signed-off-by: Tang Yizhou --- fs/fs-writeback.c | 5 ---- fs/xfs/xfs_iomap.c | 52 ++++++++++++++++++++++++--------------- include/linux/writeback.h | 5 ++++ 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d8bec3c1bb1f..31c72e207e1b 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -31,11 +31,6 @@ #include #include "internal.h" -/* - * 4MB minimal write chunk size - */ -#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_SHIFT - 10)) - /* * Passed into wb_writeback(), essentially a subset of writeback_control */ diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 1e11f48814c0..80f759fa9534 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -4,6 +4,8 @@ * Copyright (c) 2016-2018 Christoph Hellwig. * All Rights Reserved. */ +#include + #include "xfs.h" #include "xfs_fs.h" #include "xfs_shared.h" @@ -744,6 +746,34 @@ xfs_ilock_for_iomap( return 0; } +/* + * We cap the maximum length we map to a sane size to keep the chunks + * of work done where somewhat symmetric with the work writeback does. + * This is a completely arbitrary number pulled out of thin air as a + * best guess for initial testing. + * + * Following the logic of writeback_chunk_size(), the length will be + * rounded to the nearest 4MB boundary. + * + * Note that the values needs to be less than 32-bits wide until the + * lower level functions are updated. + */ +static loff_t +xfs_max_map_length(struct inode *inode, loff_t length) +{ + struct bdi_writeback *wb; + long pages; + + spin_lock(&inode->i_lock); + wb = inode_to_wb(wb); + pages = min(wb->avg_write_bandwidth / 2, + global_wb_domain.dirty_limit / DIRTY_SCOPE); + spin_unlock(&inode->i_lock); + pages = round_down(pages + MIN_WRITEBACK_PAGES, MIN_WRITEBACK_PAGES); + + return min_t(loff_t, length, pages * PAGE_SIZE); +} + /* * Check that the imap we are going to return to the caller spans the entire * range that the caller requested for the IO. @@ -878,16 +908,7 @@ xfs_direct_write_iomap_begin( if (flags & (IOMAP_NOWAIT | IOMAP_OVERWRITE_ONLY)) goto out_unlock; - /* - * We cap the maximum length we map to a sane size to keep the chunks - * of work done where somewhat symmetric with the work writeback does. - * This is a completely arbitrary number pulled out of thin air as a - * best guess for initial testing. - * - * Note that the values needs to be less than 32-bits wide until the - * lower level functions are updated. - */ - length = min_t(loff_t, length, 1024 * PAGE_SIZE); + length = xfs_max_map_length(inode, length); end_fsb = xfs_iomap_end_fsb(mp, offset, length); if (offset + length > XFS_ISIZE(ip)) @@ -1096,16 +1117,7 @@ xfs_buffered_write_iomap_begin( allocfork = XFS_COW_FORK; end_fsb = imap.br_startoff + imap.br_blockcount; } else { - /* - * We cap the maximum length we map here to MAX_WRITEBACK_PAGES - * pages to keep the chunks of work done where somewhat - * symmetric with the work writeback does. This is a completely - * arbitrary number pulled out of thin air. - * - * Note that the values needs to be less than 32-bits wide until - * the lower level functions are updated. - */ - count = min_t(loff_t, count, 1024 * PAGE_SIZE); + count = xfs_max_map_length(inode, count); end_fsb = xfs_iomap_end_fsb(mp, offset, count); if (xfs_is_always_cow_inode(ip)) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index d6db822e4bb3..657bc4dd22d0 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -17,6 +17,11 @@ struct bio; DECLARE_PER_CPU(int, dirty_throttle_leaks); +/* + * 4MB minimal write chunk size + */ +#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_SHIFT - 10)) + /* * The global dirty threshold is normally equal to the global dirty limit, * except when the system suddenly allocates a lot of anonymous memory and