From patchwork Tue Jun 1 14:54:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 12291467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28E89C47080 for ; Tue, 1 Jun 2021 14:54:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C25EB613A9 for ; Tue, 1 Jun 2021 14:54:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C25EB613A9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EA7C96B006C; Tue, 1 Jun 2021 10:54:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E56B76B006E; Tue, 1 Jun 2021 10:54:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD0006B0070; Tue, 1 Jun 2021 10:54:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 931386B006C for ; Tue, 1 Jun 2021 10:54:38 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2A7558E5F for ; Tue, 1 Jun 2021 14:54:38 +0000 (UTC) X-FDA: 78205451436.35.3A0DD69 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf23.hostedemail.com (Postfix) with ESMTP id 30161A000245 for ; Tue, 1 Jun 2021 14:54:27 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id i22so1944031pju.0 for ; Tue, 01 Jun 2021 07:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U7TS4b0zlj5D5C5rsCw1F4eSmoRnEp26MuVRDcrEynQ=; b=mnYY7J2c2VxzicZryJmotItv56nvoLKrZDcKULJ6AepnABN6UkNxeR6pqsur3qHClA zILaNlXz5LXfZ2vgEM2AIY+ast52NBlqXAjX8tJwzUyGJpyQY73YANl0Xw5Hs8rDANfP b7ZqJAi0erpD1RT6elRm9BUgtmzAMz+fxzrLVRRE9CDyz/C/NCODFmoElWqhXD4niWxj 2jn7U3yk2cNqrFoNMU/mQmp62fdiCBwKWyTyuBwhgysLPSYYu91nBCa5AvsRm8j+z2US n4umVOAV6mnn8Gtfvpk4fyCO1pnRkBz1Obph6hkhJibfroxirAOJjpnmc/ra7PnohDVI 3zAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=U7TS4b0zlj5D5C5rsCw1F4eSmoRnEp26MuVRDcrEynQ=; b=BaQVbh8G/236vGdNbUMKLoCKtc+ThUB92mpRuBBGebREKkbsplzQLtNtr7FgaHFFsM xyoMZjqY41WQK5VXB/fSyEeeL5VKO2ZUSSh89XJJuqqjSDtzRSQd1Tj177ZodPrpCT8M RXBnrGTk6EMxgtpBJgPIRm2YVG9LTm24FxIdVwVXcoKsP8AZILSgM0o6SYKqtQbwBxEM uJJhyg47iJhYZHg2YuSB1yr9xhYhchuqQV1Gb2p0hkkEUVan3y+HOXWQV6u8xm8ZRfWr 6Tr9lb4XDFsJ397qF+tBAkT+UtVJAoC+EHP2MuxLBKi34UL4diwcaYlhFc5BpxrH56c+ ayQA== X-Gm-Message-State: AOAM53340C8c0947/VtnqnWqLk5/e1ZH3Yxnbjo4TDLevbUqooL0XT0n 1SuTxe7AhxdEOeVUmb3pq7g= X-Google-Smtp-Source: ABdhPJz0KylEhkjYi7vlWfh18rZmtFafg/cOwEjeI6XD26GQTgv3rNUz9PpM9ii1dpU+f8Yq44cd/Q== X-Received: by 2002:a17:903:2c2:b029:101:9c88:d928 with SMTP id s2-20020a17090302c2b02901019c88d928mr19242970plk.62.1622559271678; Tue, 01 Jun 2021 07:54:31 -0700 (PDT) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:90c3:9d92:1e02:1380]) by smtp.gmail.com with ESMTPSA id q24sm14539992pgk.32.2021.06.01.07.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 07:54:30 -0700 (PDT) From: Minchan Kim To: Andrew Morton Cc: Chris Goldsworthy , Laura Abbott , Oliver Sang , David Hildenbrand , John Dias , Matthew Wilcox , Michal Hocko , Suren Baghdasaryan , Vlastimil Babka , LKML , lkp@lists.01.org, lkp@intel.com, ying.huang@intel.com, feng.tang@intel.com, zhengjun.xing@intel.com, linux-mm , Minchan Kim Subject: [PATCH v2] mm: fs: invalidate bh_lrus for only cold path Date: Tue, 1 Jun 2021 07:54:25 -0700 Message-Id: <20210601145425.1396981-1-minchan@kernel.org> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog MIME-Version: 1.0 X-Rspamd-Queue-Id: 30161A000245 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mnYY7J2c; spf=pass (imf23.hostedemail.com: domain of minchankim@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=minchankim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspamd-Server: rspam04 X-Stat-Signature: 6aug4cbimnepcykqbtjtd1ojmx8tapq5 X-HE-Tag: 1622559267-892210 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: kernel test robot reported the regression of fio.write_iops[1] with [2]. Since lru_add_drain is called frequently, invalidate bh_lrus there could increase bh_lrus cache miss ratio, which needs more IO in the end. This patch moves the bh_lrus invalidation from the hot path( e.g., zap_page_range, pagevec_release) to cold path(i.e., lru_add_drain_all, lru_cache_disable). [1] https://lore.kernel.org/lkml/20210520083144.GD14190@xsang-OptiPlex-9020/ [2] 8cc621d2f45d, mm: fs: invalidate BH LRU during page migration Cc: "Xing, Zhengjun" Reported-by: kernel test robot Reviewed-by: Chris Goldsworthy Signed-off-by: Minchan Kim Reported-by: kernel test robot Signed-off-by: Minchan Kim Reviewed-by: Chris Goldsworthy --- * from v1 - https://lore.kernel.org/lkml/YK0oQ76zX0uVZCwQ@google.com/ * add Reviewed-by - cgoldswo mm/swap.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 1958d5feb148..3e25d99a9dbb 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -642,7 +642,6 @@ void lru_add_drain_cpu(int cpu) pagevec_lru_move_fn(pvec, lru_lazyfree_fn); activate_page_drain(cpu); - invalidate_bh_lrus_cpu(cpu); } /** @@ -725,6 +724,17 @@ void lru_add_drain(void) local_unlock(&lru_pvecs.lock); } +static void lru_add_and_bh_lrus_drain(void) +{ + int cpu; + + local_lock(&lru_pvecs.lock); + cpu = smp_processor_id(); + lru_add_drain_cpu(cpu); + local_unlock(&lru_pvecs.lock); + invalidate_bh_lrus_cpu(cpu); +} + void lru_add_drain_cpu_zone(struct zone *zone) { local_lock(&lru_pvecs.lock); @@ -739,7 +749,7 @@ static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work); static void lru_add_drain_per_cpu(struct work_struct *dummy) { - lru_add_drain(); + lru_add_and_bh_lrus_drain(); } /* @@ -880,7 +890,7 @@ void lru_cache_disable(void) */ __lru_add_drain_all(true); #else - lru_add_drain(); + lru_add_and_bh_lrus_drain(); #endif }