From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754275AbdBGN4k (ORCPT ); Tue, 7 Feb 2017 08:56:40 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44728 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753263AbdBGN4i (ORCPT ); Tue, 7 Feb 2017 08:56:38 -0500 From: "Aneesh Kumar K.V" To: "Kirill A. Shutemov" , Zi Yan , mgorman@techsingularity.net, riel@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kirill.shutemov@linux.intel.com, akpm@linux-foundation.org, minchan@kernel.org, vbabka@suse.cz, n-horiguchi@ah.jp.nec.com, khandual@linux.vnet.ibm.com, zi.yan@cs.rutgers.edu, Zi Yan Subject: Re: [PATCH v3 03/14] mm: use pmd lock instead of racy checks in zap_pmd_range() In-Reply-To: <20170206160751.GA29962@node.shutemov.name> References: <20170205161252.85004-1-zi.yan@sent.com> <20170205161252.85004-4-zi.yan@sent.com> <20170206160751.GA29962@node.shutemov.name> Date: Tue, 07 Feb 2017 19:25:30 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17020713-0008-0000-0000-00000107DD70 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17020713-0009-0000-0000-00000903C482 Message-Id: <87bmueqf59.fsf@skywalker.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-02-07_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702070135 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Kirill A. Shutemov" writes: > On Sun, Feb 05, 2017 at 11:12:41AM -0500, Zi Yan wrote: >> From: Zi Yan >> >> Originally, zap_pmd_range() checks pmd value without taking pmd lock. >> This can cause pmd_protnone entry not being freed. >> >> Because there are two steps in changing a pmd entry to a pmd_protnone >> entry. First, the pmd entry is cleared to a pmd_none entry, then, >> the pmd_none entry is changed into a pmd_protnone entry. >> The racy check, even with barrier, might only see the pmd_none entry >> in zap_pmd_range(), thus, the mapping is neither split nor zapped. > > That's definately a good catch. > > But I don't agree with the solution. Taking pmd lock on each > zap_pmd_range() is a significant hit by scalability of the code path. > Yes, split ptl lock helps, but it would be nice to avoid the lock in first > place. > > Can we fix change_huge_pmd() instead? Is there a reason why we cannot > setup the pmd_protnone() atomically? > > Mel? Rik? > I am also trying to fixup the usage of set_pte_at on ptes that are valid/present (that this autonuma ptes). I guess what we are missing is a variant of pte update routines that can atomically update a pte without clearing it and that also doesn't do a tlb flush ? -aneesh