From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 268E2C433E0 for ; Tue, 2 Feb 2021 20:06:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 726B164E4F for ; Tue, 2 Feb 2021 20:06:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 726B164E4F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 96F3A6B0005; Tue, 2 Feb 2021 15:06:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91EBB6B0006; Tue, 2 Feb 2021 15:06:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83E616B006C; Tue, 2 Feb 2021 15:06:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 6DF2F6B0005 for ; Tue, 2 Feb 2021 15:06:15 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 375308249980 for ; Tue, 2 Feb 2021 20:06:15 +0000 (UTC) X-FDA: 77774409510.22.order38_3d05168275cd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id D860118038E68 for ; Tue, 2 Feb 2021 20:06:14 +0000 (UTC) X-HE-Tag: order38_3d05168275cd X-Filterd-Recvd-Size: 4134 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 20:06:14 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id CE32E64DDC; Tue, 2 Feb 2021 20:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1612296373; bh=UUCbeiKruohgPLn70yuv5yyi43xYXqhUx5aEilibtwQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mMPFuutry6yvrlRsX/cFk7nH6IhMcJEMn6CHKOk1bu/3K+vi8oRsOD2Un9VPFWZsO QqyfnUPoy0t+3JNCALRZJXK/mMzOJd5LtkWbN/RaA3xgbMgbxGkch1znJquQiCK9VK +YvgSnZtX8t9t9jG4aCkMCjWS/C0/OkE48M6pIak= Date: Tue, 2 Feb 2021 12:06:12 -0800 From: Andrew Morton To: Chris Goldsworthy Cc: Alexander Viro , Minchan Kim , Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [RFC] mm: fs: Invalidate BH LRU during page migration Message-Id: <20210202120612.2678f10bbc48734225c690bb@linux-foundation.org> In-Reply-To: <695193a165bf538f35de84334b4da2cc3544abe0.1612248395.git.cgoldswo@codeaurora.org> References: <695193a165bf538f35de84334b4da2cc3544abe0.1612248395.git.cgoldswo@codeaurora.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: On Mon, 1 Feb 2021 22:55:47 -0800 Chris Goldsworthy wrote: > Pages containing buffer_heads that are in the buffer_head LRU cache > will be pinned and thus cannot be migrated. Correspondingly, > invalidate the BH LRU before a migration starts and stop any > buffer_head from being cached in the LRU, until migration has > finished. It's 16 pages max, system-wide. That isn't much. Please include here a full description of why this is a problem and how serious it is and of the user-visible impact. > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -1289,6 +1289,8 @@ static inline void check_irqs_on(void) > #endif > } > > +bool bh_migration_done = true; > + > /* > * Install a buffer_head into this cpu's LRU. If not already in the LRU, it is > * inserted at the front, and the buffer_head at the back if any is evicted. > @@ -1303,6 +1305,9 @@ static void bh_lru_install(struct buffer_head *bh) > check_irqs_on(); > bh_lru_lock(); > > + if (!bh_migration_done) > + goto out; > + > b = this_cpu_ptr(&bh_lrus); > for (i = 0; i < BH_LRU_SIZE; i++) { > swap(evictee, b->bhs[i]); Seems a bit hacky, but I guess it'll work. I expect the code won't compile with CONFIG_BLOCK=n && CONFIG_MIGRATION=y. Due to bh_migration_done being unimplemented. I suggest you add an interface function (buffer_block_lrus()?) and arrange for an empty inlined stub version when CONFIG_BLOCK=n. > > .. > > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -64,6 +64,19 @@ > */ > void migrate_prep(void) > { > + bh_migration_done = false; > + > + /* > + * This barrier ensures that callers of bh_lru_install() between > + * the barrier and the call to invalidate_bh_lrus() read > + * bh_migration_done() as false. > + */ > + /* > + * TODO: Remove me? lru_add_drain_all() already has an smp_mb(), > + * but it would be good to ensure that the barrier isn't forgotten. > + */ > + smp_mb(); This stuff can be taken care of over in buffer_block_lrus() in fs/buffer.c. > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > > @@ -759,6 +760,8 @@ void lru_add_drain_all(void) > if (WARN_ON(!mm_percpu_wq)) > return; > > + invalidate_bh_lrus(); > + Add a comment explaining why we're doing this? Mention that bn_lru buffers can pin pages, preventing migration.