Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1292096ybv; Thu, 13 Feb 2020 20:09:13 -0800 (PST) X-Google-Smtp-Source: APXvYqyk1QN0mQfwmZPmUmZPGevDJw2ShfAm9lX/uMmPK8Mk/dOpDv1GiCizL5TWY6TBgrJ5dcvF X-Received: by 2002:a9d:5784:: with SMTP id q4mr742541oth.278.1581653353177; Thu, 13 Feb 2020 20:09:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581653353; cv=none; d=google.com; s=arc-20160816; b=yVddI3nmfo810YNBFsMdBj2y5d6mIoSza4n6VWogqTeDhZ2oBk9YPB93NpaU6cUk+1 +aYeVPatjGmcImZlPk0q4G6ZQS4Zl92Ednnjhl7YITKkVpeoUaRX3dShSOuRFSfjEarJ kPaHpDcA8Ov32yzY87k9SQlUjKzsSUeUxTN9w9eXcv9MQaD7gNpsMx2tSPNBv0kv+ySb wWyj+MZTdMMpgcd4hPEkHLQcHSb81umbmYYzTe3Lde6mA2MAux9NkFXuCES7BGF4Fmsr xGR/QEMTGJG4z1LK7cJBV3Jb7ERNyq75xe4Dmm9YN0zbj7cugLv3UF4bO3RYcqNV3kaa VFNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=a/kS7RBgvMPezQ8mrVCoFpKH0m8y283o0jw3J9zoGew=; b=yEthlFYRFa8EtYIsjuw5/ubjtHDXPi/vUhCvLGZQ57SmU7FZuTVIF4+5yLmnugOy2f WdRayz8lRvrvTJ40wyN+F7isTx/R8AI6y8YKhnwqPJ7xrtgzX1LUFzadJG06AF7LdzqJ 725i2Zp/jf9XdvJ6Mcyn297mveBV4P16qaPSC4p6GNd339EdTsPeX0drAXVLuA2jSa23 uzN84efEYltiPVrnLUUBObxNHNR9XnUqtjeikrsqmFp2Una1fhKHDkwDXt/m2uhMnHgo TULw9wdBAkDIg3ZeMmoNcpdMCU1U2GhXkq5BzMbeUEj6BYSXLKu2R/xsQsrTzD52/16r 926g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZFLtWz86; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b191si2008925oii.266.2020.02.13.20.09.00; Thu, 13 Feb 2020 20:09:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZFLtWz86; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728571AbgBNEH2 (ORCPT + 99 others); Thu, 13 Feb 2020 23:07:28 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39466 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728479AbgBNEH2 (ORCPT ); Thu, 13 Feb 2020 23:07:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=a/kS7RBgvMPezQ8mrVCoFpKH0m8y283o0jw3J9zoGew=; b=ZFLtWz86Yr7Hs41S4dTIXvIb8M K8bwkhbY1QKk5Wsz0QJ4Ov1SDMXk1StCcvh4WDKxlFNbNZDRvaVD/T1Fxr24mcx+MVm9EtxdhxMBi /7ERHgAJM/ghzrmnYqs0pC/PKWH7krgrsMQNM8h48RK8sqE6GKWlyCGOMS6m19GR6kK9Xfi5NlinU DvlbsLV0YKUwmNFYCMZR1ff0GjnQiyDfPN2xgU9iDP1Tm/k3Wyyvgsi6YVyTx/LrR6FINmP/KSJGM LhyLRvug299r2QflD7lDbOjbbm8kmKUAIiaq8NlcUoK0BH/G3fDKDmY7LrBQhuaQbHpsrZCSjEbdE jLYmN+4Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j2SGC-00040d-T1; Fri, 14 Feb 2020 04:07:24 +0000 Date: Thu, 13 Feb 2020 20:07:24 -0800 From: Matthew Wilcox To: Yang Shi Cc: Andrew Morton , mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: migrate.c: migrate PG_readahead flag Message-ID: <20200214040724.GV7778@bombadil.infradead.org> References: <1581640185-95731-1-git-send-email-yang.shi@linux.alibaba.com> <20200213185511.4660aca17553562d764dc7ea@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 13, 2020 at 07:58:40PM -0800, Yang Shi wrote: > On 2/13/20 6:55 PM, Andrew Morton wrote: > > On Fri, 14 Feb 2020 08:29:45 +0800 Yang Shi wrote: > > > Currently migration code doesn't migrate PG_readahead flag. > > > Theoretically this would incur slight performance loss as the > > > application might have to ramp its readahead back up again. Even though > > > such problem happens, it might be hidden by something else since > > > migration is typically triggered by compaction and NUMA balancing, any > > > of which should be more noticeable. > > > > > > Migrate the flag after end_page_writeback() since it may clear > > > PG_reclaim flag, which is the same bit as PG_readahead, for the new > > > page. > > > > > > --- a/mm/migrate.c > > > +++ b/mm/migrate.c > > > @@ -647,6 +647,14 @@ void migrate_page_states(struct page *newpage, struct page *page) > > > if (PageWriteback(newpage)) > > > end_page_writeback(newpage); > > > + /* > > > + * PG_readahead share the same bit with PG_reclaim, the above > > > + * end_page_writeback() may clear PG_readahead mistakenly, so set > > > + * the bit after that. > > > + */ > > > + if (PageReadahead(page)) > > > + SetPageReadahead(newpage); > > > + > > > copy_page_owner(page, newpage); > > Why not > > The newpage may not have writeback set, migrating readahead flag should not > depend on it. Indeed, if the page has writeback set, then the page does not have the readahead flag set; it has the reclaim flag set. The original patch is correct, afaict. > > if (PageWriteback(newpage)) { > > end_page_writeback(newpage); > > /* > > * PG_readahead share the same bit with PG_reclaim, the above > > * end_page_writeback() may clear PG_readahead mistakenly, so > > * set the bit after that. > > */ > > if (PageReadahead(page)) > > SetPageReadahead(newpage); > > } > > > > ? >