Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752615AbdCFCtS (ORCPT ); Sun, 5 Mar 2017 21:49:18 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59134 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752543AbdCFCtR (ORCPT ); Sun, 5 Mar 2017 21:49:17 -0500 From: "Aneesh Kumar K.V" To: "Kirill A. Shutemov" , Andrea Arcangeli , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Minchan Kim Subject: Re: [PATCH 3/4] thp: fix MADV_DONTNEED vs. MADV_FREE race In-Reply-To: <20170302151034.27829-4-kirill.shutemov@linux.intel.com> References: <20170302151034.27829-1-kirill.shutemov@linux.intel.com> <20170302151034.27829-4-kirill.shutemov@linux.intel.com> Date: Mon, 06 Mar 2017 08:19:03 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030602-0004-0000-0000-00000549F81F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030602-0005-0000-0000-000013466779 Message-Id: <871subdsrk.fsf@skywalker.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-06_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=5 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703060023 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1252 Lines: 35 "Kirill A. Shutemov" writes: > Basically the same race as with numa balancing in change_huge_pmd(), but > a bit simpler to mitigate: we don't need to preserve dirty/young flags > here due to MADV_FREE functionality. > > Signed-off-by: Kirill A. Shutemov > Cc: Minchan Kim > --- > mm/huge_memory.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index bb2b3646bd78..324217c31ec9 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -1566,8 +1566,6 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, > deactivate_page(page); > > if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) { > - orig_pmd = pmdp_huge_get_and_clear_full(tlb->mm, addr, pmd, > - tlb->fullmm); > orig_pmd = pmd_mkold(orig_pmd); > orig_pmd = pmd_mkclean(orig_pmd); > Instead can we do a new interface that does something like pmdp_huge_update(tlb->mm, addr, pmd, new_pmd); We do have a variant already in ptep_set_access_flags. What we need is something that can be used to update THP pmd, without converting it to pmd_none and one which doens't loose reference and change bit ? -aneesh