Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp680090pxa; Wed, 19 Aug 2020 11:50:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEMKueOPicmQJ/DvgdPCh8ibBDqQTQhRmnwD0tDufww+BDCthuCgBfil7FJZvykeQLgJTG X-Received: by 2002:a17:906:ce39:: with SMTP id sd25mr27940018ejb.80.1597863035919; Wed, 19 Aug 2020 11:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597863035; cv=none; d=google.com; s=arc-20160816; b=INuf1MRw2f5euLchDf6ypZ/AjwMDyYweB9WNZS+PDXQDvckAnnL6otAHO7rAqsGuJI Mv8NgrC9mSErmv6sFeBaKkuT02DC7MBT4TjTyq3XGtJYEKxMJx9uRB+ZHy8TOWfXqpbw rPEetqJMGiVSoP1Zk1GGpHE+S/AE2u/3k13IWf1F4v4CsD3B/Xuh/gqi/YB3cHr0G31r 79lJeDN7xkod0f9wYnj4VaY18CBqixF8j42UQWLmYtadjonbb3XS7mLXv04mXdnekCRD ulfBuvocOqdSr0HThhLVh6D5n/u2WsyJd+TuJE+OYKmZMbl58qDElnoZY7MKXfCafPJw TsYw== 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=66DP4Pf9efccaQIqwctMuv9XwKLU5wWgwMF4qWqr0Vk=; b=Eu1FFrCYRf1r71KHyLXPOs0K/8sUo4JbpBwrcBwCgtqidNEup1tgmkjpkVk49FBk8X QHFfG79kWmeTk4uS5i3nBJjV5VAOPfRc5Oj96gxwkn6aXKTUQ7t98eVAdUi1fXN5VuMV NDJEC6pCf5dtBpcXHpCPtYfIiuslhRh/XyjHHW753vdqtm6EwXy/fT5gTaEfkJHOr3rq mxaIsbOPqRTdu+ZUvsQTious4Ll5jBgm1TsjVXZqFuuF00reTCQechYI+vl3QAkbAwf4 iUSUyStEMsUmIKKDmvDCbzwNxyY4dRnQuKrm8b8Sx7Za9rj4NURQDbCsIQoA82Uz0nIz OF6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=b4pHEvLP; 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 q27si16113669ejd.123.2020.08.19.11.50.12; Wed, 19 Aug 2020 11:50:35 -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=b4pHEvLP; 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 S1726920AbgHSStZ (ORCPT + 99 others); Wed, 19 Aug 2020 14:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726862AbgHSStJ (ORCPT ); Wed, 19 Aug 2020 14:49:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2631FC061342; Wed, 19 Aug 2020 11:49:09 -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=66DP4Pf9efccaQIqwctMuv9XwKLU5wWgwMF4qWqr0Vk=; b=b4pHEvLPG1hkKsnmbfQrrqTHYi VWkIBNDtjyN9c8Z4LmNDcpjHj7yq6xtVSvSuiJUBrLhJ6I96lrnl+ChJ/s76uL2F4feghrlNFAQ1N MsxinyVoKVilyk25tpijsshqsL4+yiO4m5XrhCgIu6pXy0OOAd7tzIkD89C5t7Qz1KUbuj5qz01fd MSmojCrJigJEHzAYVnM3DkoJTYfyYNJlXIZjcizjLjuA9IesPN3cy97gRx00+1QRiJdbmQw8GmnLe IJOGDVShbQY8CWQ6aDu09E/pboQS5RIZ4Q1K2ryIsClNEi9KQZN5QbfFYiHPrEQ9S1eZ6yfVivX38 rEAPV0mw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8T8n-0006Sx-83; Wed, 19 Aug 2020 18:48:53 +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 2/8] mm: Use find_get_swap_page in memcontrol Date: Wed, 19 Aug 2020 19:48:44 +0100 Message-Id: <20200819184850.24779-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200819184850.24779-1-willy@infradead.org> References: <20200819184850.24779-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 | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b807952b4d43..4075f214a841 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5539,35 +5539,14 @@ 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_swap_page(vma->vm_file->f_mapping, + linear_page_index(vma, addr)); } /** -- 2.28.0