Received: by 10.213.65.68 with SMTP id h4csp1348793imn; Wed, 14 Mar 2018 18:21:11 -0700 (PDT) X-Google-Smtp-Source: AG47ELtiVgPvdRm25+xomUg1yRGzNI9LXWx9HQ18W+CMrrgZkQ7xZTw25Y7GcsDY8JLMMaTFWdwY X-Received: by 10.98.76.155 with SMTP id e27mr4581246pfj.45.1521076871606; Wed, 14 Mar 2018 18:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521076871; cv=none; d=google.com; s=arc-20160816; b=uQSU3f6pzrhJ0vDpO6J+i0chJp06KllY0HJZTjpNMTmnD/fWz4kd43TLW1FlQV7Lcj 2lWdSXvBDZpuZOMveGc6up5eA8dnZz/vK9BtkmzlttDj4D7uR+damCsIqqtt2Y+EYOxp 8pYdtwXI/Y7wy+Pz8qz8uRw/2YOrncJr2i1tDAPdw1U8BjRWV9pKqT+vasNQ7YBuN1rQ w8B4ZNIVMYEYr/hJJcsEIz1S0aoe5VRwYfs50ZNTY7z0n57Rtti0yvT4IqEstLX7NJ5q JDALx2f5B/Xyi+0UbFn+jhw0/95W8dUMNAoueGZG6mHGn3etBcBDT7No4orlyCJBPR/C Adbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=svfYIJjM3fmWmY8cCgENhlZ/LjeMr5FXWphwDdoTgzE=; b=sri+s0MTHG72WPTQZM09Aj5bEzE3ra/RgyxG94vOG8mcuTpZSp+d/nKGB3hRAlhnN/ xOSP3kFxvC+mpOFqHSZI0C0jatnvPr7Mze/Ko/7e4t/9sSfCrH4Grr7Pc+iMr7ue+fBm mzMYCYkg/kPIz9umJbE0GIZgwai+qWQbOM0pBZ7G6pkT4Lro0J0FafTLkJHA7iVfBl1O Ik+JXHRH8SW9yWDnVOfWw1nScIPt5m4vSWD/K0tRzONBdtKQ08BvkXEa/b6VU7mcS0Gk dj6DmXmXxln3gWt+kbWlf1JoWCj7ZZ900bkZagnm9OuKLuscsHUEfgFpMawVQMSJGfX/ dXkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si2708065pgo.349.2018.03.14.18.20.45; Wed, 14 Mar 2018 18:21:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751555AbeCOBTU (ORCPT + 99 others); Wed, 14 Mar 2018 21:19:20 -0400 Received: from mga14.intel.com ([192.55.52.115]:60023 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbeCOBTT (ORCPT ); Wed, 14 Mar 2018 21:19:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2018 18:19:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,308,1517904000"; d="scan'208";a="182872805" Received: from unknown (HELO yhuang-mobile.sh.intel.com) ([10.239.197.95]) by orsmga004.jf.intel.com with ESMTP; 14 Mar 2018 18:19:15 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , "Kirill A. Shutemov" , Michal Hocko , Minchan Kim , Shaohua Li , Zi Yan , jglisse@redhat.com, "Aneesh Kumar K.V" Subject: [PATCH -mm] mm, madvise, THP: Use THP aligned address in madvise_free_huge_pmd() Date: Thu, 15 Mar 2018 09:18:40 +0800 Message-Id: <20180315011840.27599-1-ying.huang@intel.com> X-Mailer: git-send-email 2.16.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Ying The address argument passed in madvise_free_huge_pmd() may be not THP aligned. But some THP operations like pmdp_invalidate(), set_pmd_at(), and tlb_remove_pmd_tlb_entry() need the address to be THP aligned. Fix this via using THP aligned address for these functions in madvise_free_huge_pmd(). Signed-off-by: "Huang, Ying" Cc: "Kirill A. Shutemov" Cc: Michal Hocko Cc: Minchan Kim Cc: Shaohua Li Cc: Zi Yan Cc: jglisse@redhat.com Cc: "Aneesh Kumar K.V" --- mm/huge_memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 0cc62405de9c..c5e1bfb08bd7 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1617,6 +1617,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, struct page *page; struct mm_struct *mm = tlb->mm; bool ret = false; + unsigned long haddr = addr & HPAGE_PMD_MASK; tlb_remove_check_page_size_change(tlb, HPAGE_PMD_SIZE); @@ -1663,12 +1664,12 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, unlock_page(page); if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) { - pmdp_invalidate(vma, addr, pmd); + pmdp_invalidate(vma, haddr, pmd); orig_pmd = pmd_mkold(orig_pmd); orig_pmd = pmd_mkclean(orig_pmd); - set_pmd_at(mm, addr, pmd, orig_pmd); - tlb_remove_pmd_tlb_entry(tlb, pmd, addr); + set_pmd_at(mm, haddr, pmd, orig_pmd); + tlb_remove_pmd_tlb_entry(tlb, pmd, haddr); } mark_page_lazyfree(page); -- 2.16.1