From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00AC4C43381 for ; Fri, 22 Mar 2019 08:25:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C383D21873 for ; Fri, 22 Mar 2019 08:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727538AbfCVIZH (ORCPT ); Fri, 22 Mar 2019 04:25:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52448 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbfCVIZG (ORCPT ); Fri, 22 Mar 2019 04:25:06 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2M8OwWs043046 for ; Fri, 22 Mar 2019 04:25:05 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rct68w69x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Mar 2019 04:25:01 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Mar 2019 08:23:47 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 22 Mar 2019 08:23:45 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2M8NmVu41812204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 08:23:48 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D50911C04C; Fri, 22 Mar 2019 08:23:48 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 73FDC11C04A; Fri, 22 Mar 2019 08:23:46 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.85.68.197]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Mar 2019 08:23:45 +0000 (GMT) X-Mailer: emacs 26.1 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Andrew Morton Cc: "Kirill A . Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dan Williams , Andrea Arcangeli Subject: Re: [PATCH] mm: page_mkclean vs MADV_DONTNEED race In-Reply-To: <20190321163147.cc2ff090a7388cdb7030eed0@linux-foundation.org> References: <20190321040610.14226-1-aneesh.kumar@linux.ibm.com> <20190321163147.cc2ff090a7388cdb7030eed0@linux-foundation.org> Date: Fri, 22 Mar 2019 13:53:42 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 19032208-0012-0000-0000-00000305D4AD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19032208-0013-0000-0000-0000213CEF9A Message-Id: <8736nf8ghd.fsf@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-22_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903220065 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrew Morton writes: > On Thu, 21 Mar 2019 09:36:10 +0530 "Aneesh Kumar K.V" wrote: > >> MADV_DONTNEED is handled with mmap_sem taken in read mode. >> We call page_mkclean without holding mmap_sem. >> >> MADV_DONTNEED implies that pages in the region are unmapped and subsequent >> access to the pages in that range is handled as a new page fault. >> This implies that if we don't have parallel access to the region when >> MADV_DONTNEED is run we expect those range to be unallocated. >> >> w.r.t page_mkclean we need to make sure that we don't break the MADV_DONTNEED >> semantics. MADV_DONTNEED check for pmd_none without holding pmd_lock. >> This implies we skip the pmd if we temporarily mark pmd none. Avoid doing >> that while marking the page clean. >> >> Keep the sequence same for dax too even though we don't support MADV_DONTNEED >> for dax mapping > > What were the runtime effects of the bug? The bug was noticed by code review and I didn't observe any failures w.r.t test run. This is similar to commit 58ceeb6bec86d9140f9d91d71a710e963523d063 Author: Kirill A. Shutemov Date: Thu Apr 13 14:56:26 2017 -0700 thp: fix MADV_DONTNEED vs. MADV_FREE race commit ced108037c2aa542b3ed8b7afd1576064ad1362a Author: Kirill A. Shutemov Date: Thu Apr 13 14:56:20 2017 -0700 thp: fix MADV_DONTNEED vs. numa balancing race > > Did you consider a -stable backport? Considering nobody reported issues w.r.t MADV_DONTNEED I was not sure. -aneesh