From patchwork Wed Feb 28 09:19:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 207570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3071754dyb; Tue, 27 Feb 2024 17:25:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXmgB4x+wUUZv9wtCP9D622EcM4MnEOGtgx68NnfWs/JLNQb2rB+qTqPdK26Odfv9TjrojDzHuhtr/LwKu6cev+MeTm5w== X-Google-Smtp-Source: AGHT+IFSU7FZu/shkV8ZcUX4bg3ar1zjcfNbRThigMFGKBwmoz6kuEFXSCXPIcbP5wjEdQCMfyC4 X-Received: by 2002:a05:6359:4c26:b0:17b:c7b8:be7f with SMTP id kj38-20020a0563594c2600b0017bc7b8be7fmr3167328rwc.32.1709083551809; Tue, 27 Feb 2024 17:25:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709083551; cv=pass; d=google.com; s=arc-20160816; b=pmMdGY0RHOvq4rO91J5FJgT1twK8n6esTQc41hM1K6hjh26BNrmwtt05ZwLYSfJjwo P05Sp2qxMk0b36LPRcOl5tg0eCqnfaKIE/0da0RyiMhhW6iT4HfAgpHlsG0AV1/9DoJ0 oY9/gzqHcx9LJViHribX9Pu/ohobIMI9J6/i/3QOL4FRqZxautAYd/qCaNbxoNyUHfil ohA0JSsRndJwGkjvqm1PCElY7GLIn+WSAKh+3u1M0h4dtIJPWGjIvq0cMrDzHnzTHJWI RMV96hIqy3OJEW+VAGWpkbHkU6Vx7+pFJGAB0bq0mKjWqQfWwjHzVBo+abARoauwD85I udvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=FMMKc5dm7oGwPVnCfdovJL3oFncFeHb4dVX3GVkHgkM=; fh=y/7Wtt5UOSj/SCUlHdmMQBdr226cA96uA6lTOGta4DA=; b=CAYa6B7/fw0yp3wsU/xTwa6OVAp55ctEChdntpmFifN9PJyschniur29rtzi+1Rk9K hMz3S9I5Wr4UNKKyx9VYw0v+hQtFduC1wNMwEoLBA6zROCr4/MDsaVZ7CwUkYGj94a3E Llfw/m//kkc4FhWZdUztdadFulzoWd26mSL7enPFVjvmxwp9pF1zkFidTnI3rYYcfYRQ vcHC67PgZ/pgew/myCJb9PAeGUWntFj6siblUyrnjpRVwQdYpMd2TPXjBFNAnvkxjakb 6JX3PD1Tsrpim7bxB7g6M/r8YQP/DKevoeIUjXGyD6FPz/v0ApoFzh/Jab4V6PBYqLf+ W31A==; 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-84327-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84327-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y73-20020a638a4c000000b005d778417e50si6578562pgd.587.2024.02.27.17.25.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:25:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84327-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-84327-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84327-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CF952838F3 for ; Wed, 28 Feb 2024 01:25:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73A2B2135A; Wed, 28 Feb 2024 01:23:18 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 D4326FBED; Wed, 28 Feb 2024 01:23:13 +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=1709083395; cv=none; b=ATPrBcSJO/IskJgntrhEI86rsIddrXQ6w4b8l4dBe5oXBm8QKTJzER39bpRNcIttDzRReZz6iv1Wh0QeVOV2sLX49joR60t48j/m+AQ1YPPd3ZgEvH3bkW2gumRBj4f8VyEY/HREAsV+UmzfLg2+EBRSrTpcy0thvuGrUOeEGgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709083395; c=relaxed/simple; bh=wobu9kkXF6/BimHszN+V9hX7lzwqQsw+Tts6H4/vFXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BiJ6e1Vc76rJ/2BumVQHSej3xnSr0OJcmXAZPBjvSInfNKGAsuXPygAzcTKQW6Ky8FxCQaqqskog8wSnfTB4Txa13xxzjS9RQ/eXB3N05k9LdIsgbj2KBnsPx4Q3VPxqIiVMit/EhkBSvvlqydIe2ALOHLf91D4jXzAdEkY3rrA= 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 4TkxSC1QSLz4f3kK0; Wed, 28 Feb 2024 09:23:07 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 89F3B1A056D; Wed, 28 Feb 2024 09:23:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDX8gv7it5lqQx6FQ--.57137S6; Wed, 28 Feb 2024 09:23:10 +0800 (CST) From: Kemeng Shi To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, tim.c.chen@linux.intel.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] fs/writeback: only calculate dirtied_before when b_io is empty Date: Wed, 28 Feb 2024 17:19:56 +0800 Message-Id: <20240228091958.288260-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240228091958.288260-1-shikemeng@huaweicloud.com> References: <20240228091958.288260-1-shikemeng@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgDX8gv7it5lqQx6FQ--.57137S6 X-Coremail-Antispam: 1UD129KBjvJXoW7tFy3uF17Kw17ZF45XFWUJwb_yoW8GFWrpF Zxt34Skr4jva1Sgrn7A3W29r1Fgw48GF47A3yxZFyfZw13Za42ga4Dt348Kw1kJr47Xr9a vws5GFWxC340yr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAv FVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJw A2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE 3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr2 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUIL05UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792103994454564880 X-GMAIL-MSGID: 1792103994454564880 The dirtied_before is only used when b_io is not empty, so only calculate when b_io is not empty. Signed-off-by: Kemeng Shi --- fs/fs-writeback.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 1c3134817865..c98684e9e6ba 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2105,20 +2105,21 @@ static long wb_writeback(struct bdi_writeback *wb, spin_lock(&wb->list_lock); - /* - * Kupdate and background works are special and we want to - * include all inodes that need writing. Livelock avoidance is - * handled by these works yielding to any other work so we are - * safe. - */ - if (work->for_kupdate) { - dirtied_before = jiffies - - msecs_to_jiffies(dirty_expire_interval * 10); - } else if (work->for_background) - dirtied_before = jiffies; - trace_writeback_start(wb, work); if (list_empty(&wb->b_io)) { + /* + * Kupdate and background works are special and we want + * to include all inodes that need writing. Livelock + * avoidance is handled by these works yielding to any + * other work so we are safe. + */ + if (work->for_kupdate) { + dirtied_before = jiffies - + msecs_to_jiffies(dirty_expire_interval * + 10); + } else if (work->for_background) + dirtied_before = jiffies; + queue_io(wb, work, dirtied_before); queued = true; }