Received: by 10.223.185.116 with SMTP id b49csp3397942wrg; Tue, 13 Feb 2018 01:47:55 -0800 (PST) X-Google-Smtp-Source: AH8x224Z9FN15KnrnCKi0CTHvO6wAcZwk6GwKQ4BlJaNxSKeggwCublRwJX/mTrUcrt709H6VHvJ X-Received: by 10.99.120.143 with SMTP id t137mr536200pgc.79.1518515275334; Tue, 13 Feb 2018 01:47:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518515275; cv=none; d=google.com; s=arc-20160816; b=XRCLAfexygaXj407dP1DG4C3GB9l2VQuj8WFpGxLoERzZlPl+dkgY4/Ef7T1gf/Tm4 be9xRhxijbCzioEiZwm8A7+Xza1wHlGnjzvtFUI3Stfdl7QHExAvIPcAKCjNtAJKgk5B 0FEDfWzcBPYtvOOpvMhYc+vwse5WZxFkEUdVSRgyK9YOOf6YUhBOLMF/ps/BmjQ/FRAV IGdNOJAL8kZ+RfAooKyDLDeOj0t2EtetMum4hC55DuEXg59VVG4e91vT6IoL3FRdPrx5 oYpPS8Ty0XWkMFWe0lDNFwCqRZjP3GLbcI6rOmATlPKzfMgVXmerOCPymIZPidZ2k4h6 PdNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date :arc-authentication-results; bh=YPzwKm/nhLC/8x+Im6YD9OsE/3w5EGeVIqxVkzGS4lI=; b=gJWdfbd0i1q3CCAeQt8ReIMCm1SVIypG13RdcktoHjFVqK+0sxGbpGZHIcalj6zjz5 gnyKLqCWAVvaieBl/If9r9i+ryRzdwgUU60W+laGJ2pS/Tj8yQF9M1IHbGdIdrJycrOR f5Fhjtmc2YVh7f05ir0LGr8cmz3C/GJSQsub6SqKSCnd3mge24fPsFZdtya5qMY7ybHB IxejKlm7mmCr5r+k4HyvdNw4sQbUPKEja1G7Uz/F058orpyF8JNKq90oFzQ3r+aHyGiD pzakFLjNwrnnzGAHPORS1E+X097bvjYAuZpnq6KJQrQlMEMaWADxchB3Hzz2aqK0TVF6 loew== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22-v6si1016227plk.550.2018.02.13.01.47.40; Tue, 13 Feb 2018 01:47:55 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934613AbeBMJq1 (ORCPT + 99 others); Tue, 13 Feb 2018 04:46:27 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49468 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934268AbeBMJqW (ORCPT ); Tue, 13 Feb 2018 04:46:22 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1D9kGAW046293 for ; Tue, 13 Feb 2018 04:46:21 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g3wjqr7y3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 13 Feb 2018 04:46:21 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Feb 2018 09:46:19 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Feb 2018 09:46:14 -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 w1D9kD5L47907010; Tue, 13 Feb 2018 09:46:13 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21E5611C04A; Tue, 13 Feb 2018 09:39:28 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11DBA11C04C; Tue, 13 Feb 2018 09:39:27 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.109]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 13 Feb 2018 09:39:26 +0000 (GMT) Date: Tue, 13 Feb 2018 11:46:11 +0200 From: Mike Rapoport To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , Christopher Lameter , Guy Shattah , Anshuman Khandual , Michal Nazarewicz , Vlastimil Babka , David Nellans , Laura Abbott , Pavel Machek , Dave Hansen Subject: Re: [RFC PATCH 1/3] mm: make start_isolate_page_range() fail if already isolated References: <20180212222056.9735-1-mike.kravetz@oracle.com> <20180212222056.9735-2-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180212222056.9735-2-mike.kravetz@oracle.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 18021309-0008-0000-0000-000004CC3AA9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021309-0009-0000-0000-00001E5FFAF0 Message-Id: <20180213094610.GA2196@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-13_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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802130120 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 12, 2018 at 02:20:54PM -0800, Mike Kravetz wrote: > start_isolate_page_range() is used to set the migrate type of a > page block to MIGRATE_ISOLATE while attempting to start a > migration operation. It is assumed that only one thread is > attempting such an operation, and due to the limited number of > callers this is generally the case. However, there are no > guarantees and it is 'possible' for two threads to operate on > the same range. > > Since start_isolate_page_range() is called at the beginning of > such operations, have it return -EBUSY if MIGRATE_ISOLATE is > already set. > > This will allow start_isolate_page_range to serve as a > synchronization mechanism and will allow for more general use > of callers making use of these interfaces. > > Signed-off-by: Mike Kravetz > --- > mm/page_alloc.c | 8 ++++---- > mm/page_isolation.c | 10 +++++++++- > 2 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 76c9688b6a0a..064458f317bf 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -7605,11 +7605,11 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, > * @gfp_mask: GFP mask to use during compaction > * > * The PFN range does not have to be pageblock or MAX_ORDER_NR_PAGES > - * aligned, however it's the caller's responsibility to guarantee that > - * we are the only thread that changes migrate type of pageblocks the > - * pages fall in. > + * aligned. The PFN range must belong to a single zone. > * > - * The PFN range must belong to a single zone. > + * The first thing this routine does is attempt to MIGRATE_ISOLATE all > + * pageblocks in the range. Once isolated, the pageblocks should not > + * be modified by others. > * > * Returns zero on success or negative error code. On success all > * pages which PFN is in [start, end) are allocated for the caller and > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index 165ed8117bd1..e815879d525f 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -28,6 +28,13 @@ static int set_migratetype_isolate(struct page *page, int migratetype, > > spin_lock_irqsave(&zone->lock, flags); > > + /* > + * We assume we are the only ones trying to isolate this block. > + * If MIGRATE_ISOLATE already set, return -EBUSY > + */ > + if (is_migrate_isolate_page(page)) > + goto out; > + > pfn = page_to_pfn(page); > arg.start_pfn = pfn; > arg.nr_pages = pageblock_nr_pages; > @@ -166,7 +173,8 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages) > * future will not be allocated again. > * > * start_pfn/end_pfn must be aligned to pageblock_order. > - * Returns 0 on success and -EBUSY if any part of range cannot be isolated. > + * Returns 0 on success and -EBUSY if any part of range cannot be isolated Nit: please s/Returns/Return:/ and keep the period in the end > + * or any part of the range is already set to MIGRATE_ISOLATE. > */ > int start_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, > unsigned migratetype, bool skip_hwpoisoned_pages) > -- > 2.13.6 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org > -- Sincerely yours, Mike.