Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp391920ybt; Wed, 8 Jul 2020 02:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM5132gO64c0Af0kbaRr2T83GLsByT66ZfnpPKpsL9bQboDxbj7AUHYHjQoqZQUKp51jNq X-Received: by 2002:aa7:dc46:: with SMTP id g6mr61189185edu.194.1594200499281; Wed, 08 Jul 2020 02:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594200499; cv=none; d=google.com; s=arc-20160816; b=GIiSHKE8ROe+H/RH9L1eHdkH8dkS4H0bsbMFWt6BE340AZrphZfX4zCWQt/d2L+XM6 CyNm/9OZOjLJUfcrNMjpT32OSN9p+a7b09xtsHQ8qVDGEHgq/qvd8diwCEESPDaIoFfn Lx3pmRo9/uTN4MB+qWUUFO9Q9+2cdBNtjB/hsHSqPe7imZBQ6pXA70nK9zkfaNRrj5GU fHG/Ufb+fBLRth73dJFi5cIxV/JKKqWvtQf8QZZ3gIyq+J4BEdwtxye5Sy67+gTrhU30 hSP+cb8TZUkZYaPycFaItj62Cgfi3bMuugwV2/6xcoxw4ZZhJKZ3+kANZaCWkrPmPhob 8zkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=eOS1aAHvuJ/rmxXRhEukjBr/mbTtM85QgMDhpnTllxU=; b=XejBnPGI0ZlmxMdwEKLMSLyS3c/gpbB6CC9xyb/fZtY2MgLMbQ8PVCtqHuH5YzICoP CfQpIcyNYWrD2m9CaCUL1b9NxU5nTyHxXm+Lxc8fRwRW5mA++3keK/DReEhSgu5FyPWj eC/bz0qrzs3f7g22l3wcGN60K/phh/nAwadF3GkGLSvSrZx1VZvsBvoHAbU++0xQno+O UE5xbtOG9gts38g/zJ9hT2GgFrllePfhdkRckUmc52AaSkb6GokyVnr+4n+cic0l8sEE 1OLUSDOO13GdqS4X5H7idiytX9QnFfcdtfKUGoCPP0gPYhiJ2FiN4j4/1Doj6trGDaEk YJUg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do22si19985372ejc.79.2020.07.08.02.27.54; Wed, 08 Jul 2020 02:28:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727782AbgGHJ1A (ORCPT + 99 others); Wed, 8 Jul 2020 05:27:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:48918 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgGHJ1A (ORCPT ); Wed, 8 Jul 2020 05:27:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E831EAD4D; Wed, 8 Jul 2020 09:26:58 +0000 (UTC) Subject: Re: [PATCH v4 04/11] mm/hugetlb: make hugetlb migration callback CMA aware To: 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" 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> From: Vlastimil Babka Message-ID: <8549326e-7485-dd6d-1fa1-a899228b9b2f@suse.cz> Date: Wed, 8 Jul 2020 11:26:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200708074103.GD7271@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). > 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: >