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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 4F34AC388F7 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 6FD102068D 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 6FD102068D 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) Received: by kanga.kvack.org (Postfix, from userid 40) id 653536B006C; Mon, 9 Nov 2020 08:49:00 -0500 (EST) 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-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-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 Content-Transfer-Encoding: quoted-printable 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) --- 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 =3D end / PAGE_SIZE; + pgoff_t end_index =3D linear_page_index(vma, end + PAGE_SIZE - 1); struct page *page; =20 rcu_read_lock(); --=20 2.28.0