Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752108AbdLNM4E (ORCPT ); Thu, 14 Dec 2017 07:56:04 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42854 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751297AbdLNM4C (ORCPT ); Thu, 14 Dec 2017 07:56:02 -0500 Subject: Re: [PATCH V2] mm/mprotect: Add a cond_resched() inside change_pmd_range() To: Michal Hocko , Anshuman Khandual References: <20171214111426.25912-1-khandual@linux.vnet.ibm.com> <20171214112928.GH16951@dhcp22.suse.cz> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org From: Anshuman Khandual Date: Thu, 14 Dec 2017 18:25:54 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20171214112928.GH16951@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17121412-0020-0000-0000-000003DFDF23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121412-0021-0000-0000-00004270E5D6 Message-Id: <28e54a80-73d9-76aa-31d5-f71375f14b96@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-14_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712140178 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1764 Lines: 44 On 12/14/2017 04:59 PM, Michal Hocko wrote: > On Thu 14-12-17 16:44:26, Anshuman Khandual wrote: >> diff --git a/mm/mprotect.c b/mm/mprotect.c >> index ec39f73..43c29fa 100644 >> --- a/mm/mprotect.c >> +++ b/mm/mprotect.c >> @@ -196,6 +196,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, >> this_pages = change_pte_range(vma, pmd, addr, next, newprot, >> dirty_accountable, prot_numa); >> pages += this_pages; >> + cond_resched(); >> } while (pmd++, addr = next, addr != end); >> >> if (mni_start) > > this is not exactly what I meant. See how change_huge_pmd does continue. > That's why I mentioned zap_pmd_range which does goto next... I might be still missing something but is this what you meant ? Here we will give cond_resched() cover to the THP backed pages as well. diff --git a/mm/mprotect.c b/mm/mprotect.c index ec39f73..3d445ee 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -188,7 +188,7 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, } /* huge pmd was handled */ - continue; + goto next; } } /* fall through, the trans huge pmd just split */ @@ -196,6 +196,8 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma, this_pages = change_pte_range(vma, pmd, addr, next, newprot, dirty_accountable, prot_numa); pages += this_pages; +next: + cond_resched(); } while (pmd++, addr = next, addr != end); if (mni_start)