Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp450367ybt; Wed, 8 Jul 2020 04:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9QWMNINM2h9BXU+IWTsi+ou/wmtl/5N4pBplPetMKaJbcJgg0M0b+lr6gd9ObTqA4deab X-Received: by 2002:aa7:d3c8:: with SMTP id o8mr59416372edr.294.1594206110931; Wed, 08 Jul 2020 04:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594206110; cv=none; d=google.com; s=arc-20160816; b=KJpaq/427gqGmHYzCiC0wGYVNTT5VRN0DEX8KxX9UkkigcBwDGgzrNY0cq/K8wkuvl tZQqhsAG2RtIJy2Kk5t7d8Obr98DRVMpjFfPACOWGLMrZ8pT/5hElbiGPuKwsWhyF1F6 0S3YT0+fRyniSIbg+6YHEne+PCZz9nvQNVaLC5ZbDcky5+KB12R/2t3lcPRMvjy8wPGk mYxNHexjK75rWgJPtXX6qEdZLkWkanthlCdlfqQXCuNEJ9Pc+HmpY+wNwSs4uOpXBxoI ErUYxb5QL15h9yqr0ugd6w+Rt2M6YFcBP1VGddCm7pYFu28J+xTSeWTM8GQAX0EXnB9a X7XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=++HZSQ0WBKqyQcCBz6VqueEKOGqQHO+YAaG935RLiOU=; b=ezlNYv0Y8wifTkT5HxEySXpcsSD3iw2XRqb1ntr5LwocFQGE82jXRTfyjyXrCxIcfJ SQhPsQHUC1edK43O7ZYHZyzeHApujQkmS+l4MoFP+B21LdSRmze9X7JWlTNMlumH8cyS Yz60eXS2deNOlL27aNGBRAS825dz1gZ/Jo9PSimShtUi4lvn0g1RW3L3Cy7PktgV2pJe rn7IVPU3RgHYTkUKHNUMiHBLZjtSrezSupbnWhBdKkG6R2Ih9i5sfJBW4J0pGB4SOd39 MjDtiIg0uTFfdVpCpk6ocG+JYBga6JbBkseldS6BgdE/CpudhoH9vvsqrkZKSrvyP+OO 1GEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id bh13si16369156ejb.48.2020.07.08.04.01.25; Wed, 08 Jul 2020 04:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728454AbgGHK6J (ORCPT + 99 others); Wed, 8 Jul 2020 06:58:09 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32276 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726110AbgGHK6I (ORCPT ); Wed, 8 Jul 2020 06:58:08 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 068AYSIa193645; Wed, 8 Jul 2020 06:57:24 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3256x5a8nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Jul 2020 06:57:24 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 068AYUP6193911; Wed, 8 Jul 2020 06:57:24 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 3256x5a8nn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Jul 2020 06:57:24 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 068AsS43006562; Wed, 8 Jul 2020 10:57:23 GMT Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by ppma05wdc.us.ibm.com with ESMTP id 324yf9w1hy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Jul 2020 10:57:23 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 068AvNOj41943408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Jul 2020 10:57:23 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2507828059; Wed, 8 Jul 2020 10:57:23 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F23328058; Wed, 8 Jul 2020 10:57:19 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.102.2.253]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 8 Jul 2020 10:57:19 +0000 (GMT) X-Mailer: emacs 27.0.91 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Vlastimil Babka , Michal Hocko , Joonsoo Kim Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , "Aneesh Kumar K.V" Subject: Re: [PATCH v4 04/11] mm/hugetlb: make hugetlb migration callback CMA aware In-Reply-To: <8549326e-7485-dd6d-1fa1-a899228b9b2f@suse.cz> References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> <1594107889-32228-5-git-send-email-iamjoonsoo.kim@lge.com> <20200708071602.GB16543@js1304-desktop> <20200708074103.GD7271@dhcp22.suse.cz> <8549326e-7485-dd6d-1fa1-a899228b9b2f@suse.cz> Date: Wed, 08 Jul 2020 16:27:16 +0530 Message-ID: <87h7uil1f7.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-08_07:2020-07-08,2020-07-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 cotscore=-2147483648 adultscore=0 phishscore=0 impostorscore=0 clxscore=1011 mlxlogscore=906 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007080073 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Vlastimil Babka writes: > On 7/8/20 9:41 AM, Michal Hocko wrote: >> On Wed 08-07-20 16:16:02, Joonsoo Kim wrote: >>> On Tue, Jul 07, 2020 at 01:22:31PM +0200, Vlastimil Babka wrote: >>> >>> Simply, I call memalloc_nocma_{save,restore} in new_non_cma_page(). It >>> would not cause any problem. >> >> I believe a proper fix is the following. The scope is really defined for >> FOLL_LONGTERM pins and pushing it inside check_and_migrate_cma_pages >> will solve the problem as well but it imho makes more sense to do it in >> the caller the same way we do for any others. >> >> Fixes: 9a4e9f3b2d73 ("mm: update get_user_pages_longterm to migrate pages allocated from CMA region") > > Agreed. > >> >> I am not sure this is worth backporting to stable yet. > > CC Aneesh. > > Context: since check_and_migrate_cma_pages() calls __get_user_pages_locked(), it > should also be called under memalloc_nocma_save(). But by then we faulted in all relevant pages and migrated them out of CMA rea right? > >> diff --git a/mm/gup.c b/mm/gup.c >> index de9e36262ccb..75980dd5a2fc 100644 >> --- a/mm/gup.c >> +++ b/mm/gup.c >> @@ -1794,7 +1794,6 @@ static long __gup_longterm_locked(struct task_struct *tsk, >> vmas_tmp, NULL, gup_flags); >> >> if (gup_flags & FOLL_LONGTERM) { >> - memalloc_nocma_restore(flags); >> if (rc < 0) >> goto out; >> >> @@ -1802,11 +1801,13 @@ static long __gup_longterm_locked(struct task_struct *tsk, >> for (i = 0; i < rc; i++) >> put_page(pages[i]); >> rc = -EOPNOTSUPP; >> + memalloc_nocma_restore(flags); >> goto out; >> } >> >> rc = check_and_migrate_cma_pages(tsk, mm, start, rc, pages, >> vmas_tmp, gup_flags); >> + memalloc_nocma_restore(flags); >> } >> >> out: >> -aneesh