From patchwork Mon Nov 9 13:48:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11891549 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5287D6A2 for ; Mon, 9 Nov 2020 13:49:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 89741206E3 for ; Mon, 9 Nov 2020 13:49:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dvvV6Oyj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89741206E3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6A30B6B0068; Mon, 9 Nov 2020 08:49:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 653536B006C; Mon, 9 Nov 2020 08:49:00 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51AEB6B006E; Mon, 9 Nov 2020 08:49:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 227416B0068 for ; Mon, 9 Nov 2020 08:49:00 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C39803629 for ; Mon, 9 Nov 2020 13:48:59 +0000 (UTC) X-FDA: 77465010798.25.actor97_3001d67272ec Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id A22A21804E3A8 for ; Mon, 9 Nov 2020 13:48:59 +0000 (UTC) X-Spam-Summary: 1,0,0,629633c021b8de74,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:2987:3138:3139:3140:3141:3142:3352:3865:3866:3867:5007:6261:6653:10004:11026:11658:11914:12043:12296:12297:12438:12555:12679:12895:13069:13161:13221:13229:13311:13357:13894:14096:14181:14384:14394:14721:21080:21451:21627:30054:30064,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-62.8.15.100 64.201.201.201;04yfpbpoxfnss8y44e8zbhoeootomopnn1sejgofim7k837866psfrs9g37rdfb.jqeez8ehw3iswnfsgyxkqdczd6msr9cwag9jeg9rayuwxz864kyfa7fep1h3x33.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:71,LUA_SUMMARY:none X-HE-Tag: actor97_3001d67272ec X-Filterd-Recvd-Size: 2553 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Nov 2020 13:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=izWqwdOuKPBiSqw70oUEWKY/wQqNw1TTFkFzH2zdfp0=; b=dvvV6OyjcV9K/3TbiZt+IRl488 UTzvE8GK2LQfux051OxRuBOuO8c/fStsCU0gb2jZ/qLuE0VEh63Z09rF4Gh6HizrKnG3OH3jde7/B 0Bu0JVon5dx8jj/3lj4vkP/cmg0yTtsYclYp/UfioSjcN30nq5Kfmplb893cUjOn2j4IEa5AROcqn 1CVvp/AOXohtsI+r34ToBM+Gk4T6Kv6kkr9v7kzF+2humxEzL8u0kgpDZVWbGUQ0KcqbJqkfGCxX4 3sx9MEztoZxKvBkqUFe21CcpqGBc5Pl5qgzEanDDS+8vIlPiHj1IZn4l4yNNl8TyAXG2AQA9MHhnK gaGwwcHA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc7XR-0007jw-NI; Mon, 09 Nov 2020 13:48:53 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , william.kucharski@oracle.com, feng.tang@intel.com, zhengjun.xing@intel.com, rong.a.chen@intel.com, Xing Zhengjun Subject: [PATCH] mm: Fix madvise WILLNEED performance problem Date: Mon, 9 Nov 2020 13:48:51 +0000 Message-Id: <20201109134851.29692-1-willy@infradead.org> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 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: The calculation of the end page index was incorrect, leading to a regression of 70% when running stress-ng. With this fix, we instead see a performance improvement of 3%. Reported-by: kernel test robot Tested-by: Xing Zhengjun Fixes: e6e88712e43b ("mm: optimise madvise WILLNEED") Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Johannes Weiner --- mm/madvise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/madvise.c b/mm/madvise.c index 9b065d412e5f..e602333f8c0d 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -225,7 +225,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma, struct address_space *mapping) { XA_STATE(xas, &mapping->i_pages, linear_page_index(vma, start)); - pgoff_t end_index = end / PAGE_SIZE; + pgoff_t end_index = linear_page_index(vma, end + PAGE_SIZE - 1); struct page *page; rcu_read_lock();