Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1292000pxk; Thu, 10 Sep 2020 11:40:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVl2Rb8c3XPXNAAkYkLeJZotQnwscKhwov9Re16IoyA/FegPNaECZPwjbxbi/xIo9e04VV X-Received: by 2002:a17:906:8c1:: with SMTP id o1mr10720420eje.478.1599763243246; Thu, 10 Sep 2020 11:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599763243; cv=none; d=google.com; s=arc-20160816; b=zlg307KC7NHFr0vxK1rIb6qdHnQiPzKUR9N43YRHnwW04hHX8dob6u4Vr2JLsUJNB8 cAd5N6OwzkzeYFSR+i9RLTa112xunylNgf7je429Rj4XnDoHQo6K3diFDuV3go/BOWPu b/HOEH1uOrvl+Y87JPbhqRv5Gq0s+mYVm1SlswZvhsFr6shoLNgQJm18zJFPPRaS1cT/ beewsTJui4G2jKbtH9cEBcnjODWMOO6o2HiHuW2vM7eQqQRGm49tn4Pkk3uWKTGDUJAn gBiUD9ioG+Ygv2dvwV3lFjHVENs4kxUCHyHYpjl6h+DWxD7V4GE6bf/U2xk36b9wneEH qHeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9Kn2iFLtjBF2LN/hYtvFQ/WKPU3K2jlU8w46DPT4v9k=; b=thSmLmPNEXt/zOsM8RtZrbmMeGCkvxl5UNbYkeAcE6/MXMlrJicBsD9e1sU3jrbyhZ dAR9JOXueaAO+mJPXOOydwdrQVNZChdwLz/TKGj99JidI++dVSrBPokESPZGzKRhKdMp hgsx2PMZY1m9z1m4tIdzwcZ7Q0BUa/CPxdYUS56kDiezCj+lQkcWxe3n8al498CIra94 pVRBjJEgQKEW5MSRoF6d988rS4AEzPtJ6nZ5IbgXkg4EzcrQqjCBLNlUlTka29JM6340 0NMRc2Sc5jcj7SpEifxZU0VlqaZOgWR+jgba0CqLwr0wUWQu9Vngr05j6XPO7+sG1EZ/ xtWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=t24P+wZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si4191728ejx.166.2020.09.10.11.40.20; Thu, 10 Sep 2020 11:40:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=t24P+wZG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727019AbgIJShP (ORCPT + 99 others); Thu, 10 Sep 2020 14:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbgIJSea (ORCPT ); Thu, 10 Sep 2020 14:34:30 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A29F1C061573; Thu, 10 Sep 2020 11:34:25 -0700 (PDT) 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: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9Kn2iFLtjBF2LN/hYtvFQ/WKPU3K2jlU8w46DPT4v9k=; b=t24P+wZGPBULu7P1ekGMrb5y9T +Q1IxPXTncTG4gGwrZhjgf4JJghC8ojB18ezEOesNeo4Xuqjhr0wHwKeYeiTkSWAu/RAssUiItsYh NYU5A8Djhbd24fNw+Oz5dTRDqjbttRVgFEDZVwFxAFDmZKu/vgIL+3rT5W9t2BvdUeUTKwYjFasW4 +6lT8Ru9pPL8wGIiD6mjfygYSG5lYSrgza1ShAHEuy5rL7B422LXHzNcpvSvfiupaPI4Ph8RJyLX6 bUKIAao2SDGexvS6Pn8LYeVeNjsBmywkZEQZuiQhcC54PcAvlH1iO/eZraGUIu0C56F46awFsb6qI jNq1efPg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGRNo-0005Fu-Ho; Thu, 10 Sep 2020 18:33:20 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Andrew Morton , Hugh Dickins , William Kucharski , Jani Nikula , Alexey Dobriyan , Johannes Weiner , Chris Wilson , Matthew Auld , Huang Ying , intel-gfx@lists.freedesktop.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] mm: Use find_get_incore_page in memcontrol Date: Thu, 10 Sep 2020 19:33:12 +0100 Message-Id: <20200910183318.20139-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200910183318.20139-1-willy@infradead.org> References: <20200910183318.20139-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current code does not protect against swapoff of the underlying swap device, so this is a bug fix as well as a worthwhile reduction in code complexity. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memcontrol.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b807952b4d43..2f02eaee7115 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5539,35 +5539,15 @@ static struct page *mc_handle_swap_pte(struct vm_area_struct *vma, static struct page *mc_handle_file_pte(struct vm_area_struct *vma, unsigned long addr, pte_t ptent, swp_entry_t *entry) { - struct page *page = NULL; - struct address_space *mapping; - pgoff_t pgoff; - if (!vma->vm_file) /* anonymous vma */ return NULL; if (!(mc.flags & MOVE_FILE)) return NULL; - mapping = vma->vm_file->f_mapping; - pgoff = linear_page_index(vma, addr); - /* page is moved even if it's not RSS of this task(page-faulted). */ -#ifdef CONFIG_SWAP /* shmem/tmpfs may report page out on swap: account for that too. */ - if (shmem_mapping(mapping)) { - page = find_get_entry(mapping, pgoff); - if (xa_is_value(page)) { - swp_entry_t swp = radix_to_swp_entry(page); - *entry = swp; - page = find_get_page(swap_address_space(swp), - swp_offset(swp)); - } - } else - page = find_get_page(mapping, pgoff); -#else - page = find_get_page(mapping, pgoff); -#endif - return page; + return find_get_incore_page(vma->vm_file->f_mapping, + linear_page_index(vma, addr)); } /** -- 2.28.0