From patchwork Wed Apr 5 13:37:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9664271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9922F60353 for ; Wed, 5 Apr 2017 14:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D53828588 for ; Wed, 5 Apr 2017 14:20:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81C802859A; Wed, 5 Apr 2017 14:20:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6DF2E285A3 for ; Wed, 5 Apr 2017 14:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qVOYdgCMTAWVM6QVtbGS+6IcAUZZot3EBbQszCZYvM4=; b=gGQ91TxFYb6XYtktxq75BjFu32 r/MRiY99FNPs/B93/bj5/PYo1+563n7vhsL3Ebn2e3qRE2hjOzZOnrncgAIG3+uw65QikmJyStlno tQXNVPkjyzX7WINcBNz9I4W1ynbMeneWhrmUMOIlWyNBLr8CdEO6oRwHSCIXkrG/1Hkj/wR8ywFpb ghiG4iNAos54c773LXVGa2bW1WRjEViIUSEr1Qy9Hd0yXT7O0y0Ke/UYTxK3BrAc8cni0yDVDQoil a8lPAaq8cUQ1/U988mEQfpjfDPDGLJI7Mmt0FdJQd5UKoGk3mC144H6LU/79dk3+hynrKV61VGshJ o+A5nQHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvlnb-0002JB-83; Wed, 05 Apr 2017 14:20:39 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvlnM-00025S-Qv for linux-arm-kernel@bombadil.infradead.org; Wed, 05 Apr 2017 14:20:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/5rzqRyWtZzlAJ+gODCSCOB22LXxEwxPqSHeQciOc1Q=; b=M4mo7H2jF5RqSIIdrsp0tK6Zr hVsHWGJh/M5RYI2rPLeatq89jXEqQbmFLUJvjWx3ijLdISyPmcTJxmQOzx+WL9+fgvgVWIToc66VX bJzhtyY33+yLjTiST3/vJE2luerjbfN1bFeI9zTXDk5YweqrGJ6/9ENiB1ybvi17Uf6lpcjUen5hI i8+5kNSW1EUYwl7Fv4EJpr13FC1mUW+vHIDaqeBWUc8WvXfg6/3Sx7y9tCoMFksN7EhNTfGI6rte1 8vHqbJFJvkWWYDS2TvSU4ni27B5iEct8g7h0r5WF85zCIB7DSubIWv7/iyVdyfta3t0li/ozfxdqW DQCiiOHkg==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvl8u-0000UV-Vf for linux-arm-kernel@lists.infradead.org; Wed, 05 Apr 2017 13:38:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D91921684; Wed, 5 Apr 2017 06:38:17 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.195.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AAC293F3E1; Wed, 5 Apr 2017 06:38:17 -0700 (PDT) From: Punit Agrawal To: catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org, mark.rutland@arm.com Subject: [PATCH v2 6/9] mm: rmap: Use correct helper when poisoning hugepages Date: Wed, 5 Apr 2017 14:37:19 +0100 Message-Id: <20170405133722.6406-7-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405133722.6406-1-punit.agrawal@arm.com> References: <20170405133722.6406-1-punit.agrawal@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170405_093837_151741_89F1793B X-CRM114-Status: UNSURE ( 9.01 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hillf.zj@alibaba-inc.com, Punit Agrawal , steve.capper@arm.com, tbaicar@codeaurora.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, kirill.shutemov@linux.intel.com, mike.kravetz@oracle.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Using set_pte_at() does not do the right thing when putting down HWPOISON swap entries for hugepages on architectures that support contiguous ptes. Fix this problem by using set_huge_swap_pte_at() which was introduced to fix exactly this problem. Signed-off-by: Punit Agrawal Cc: "Kirill A. Shutemov" --- mm/rmap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index f6838015810f..e07c7912a166 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1386,15 +1386,19 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, update_hiwater_rss(mm); if (PageHWPoison(page) && !(flags & TTU_IGNORE_HWPOISON)) { + pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); if (PageHuge(page)) { int nr = 1 << compound_order(page); hugetlb_count_sub(nr, mm); + set_huge_swap_pte_at(mm, address, + pvmw.pte, pteval, + vma_mmu_pagesize(vma)); } else { dec_mm_counter(mm, mm_counter(page)); + set_pte_at(mm, address, pvmw.pte, pteval); } - pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); - set_pte_at(mm, address, pvmw.pte, pteval); + } else if (pte_unused(pteval)) { /* * The guest indicated that the page content is of no