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=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 6AF98C433E2 for ; Wed, 2 Sep 2020 18:09:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 22192206EB for ; Wed, 2 Sep 2020 18:09:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="c5SKev+3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22192206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ACF9790001C; Wed, 2 Sep 2020 14:09:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7EE590000F; Wed, 2 Sep 2020 14:09:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9767E90001C; Wed, 2 Sep 2020 14:09:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 8198E90000F for ; Wed, 2 Sep 2020 14:09:11 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 422AA8248047 for ; Wed, 2 Sep 2020 18:09:11 +0000 (UTC) X-FDA: 77218908102.13.time45_130f23d270a3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id 0AF8318140B67 for ; Wed, 2 Sep 2020 18:09:10 +0000 (UTC) X-HE-Tag: time45_130f23d270a3 X-Filterd-Recvd-Size: 5448 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Sep 2020 18:09:10 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 082I8tLj164759; Wed, 2 Sep 2020 18:09:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=+vZk+VtVpEHl3xwD+/FtIt/jCERS4tTZ3n+ShA/G4Z8=; b=c5SKev+3zgSUMYyJ6hdhY49I2x4YqA+DVIb3kWngEF2T6I2lC4j3NHZF6jm7dhst9FDc dTUewii6teWfbvJPSAOVkTCokHhMSS8efyHSelNuev4tmb0Caq8PtJfG9C5HYLwav/ZX 5QBC+JW0Q0a/ssab9PzhP90SwzlIEwuGPf2xO+a6l9cxtmFIiOTuDUmm8zTancXe8pxw UzwXKtoyzmz1GKlIM1XL3JHM+iLgOlVCeGbLfliNJwYsG8IZGdO6Oor8KEXoPrdvYt+b A1sLQYvQ3XwBs4/owD98QKa0rLj3ewuD8dTf+g/6Q4nCYicRutkIGhc9j0ff4koNoz8z Ow== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 337eer4c0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 02 Sep 2020 18:09:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 082I54Wq151268; Wed, 2 Sep 2020 18:07:05 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 3380sufb5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Sep 2020 18:07:05 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 082I74f7021724; Wed, 2 Sep 2020 18:07:04 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 02 Sep 2020 11:07:03 -0700 Subject: Re: [PATCH V3] mm/hugetlb: try preferred node first when alloc gigantic page from cma To: Michal Hocko , Li Xinhai Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Roman Gushchin References: <20200902025016.697260-1-lixinhai.lxh@gmail.com> <20200902061425.GB6363@dhcp22.suse.cz> From: Mike Kravetz Message-ID: Date: Wed, 2 Sep 2020 11:07:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200902061425.GB6363@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9732 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020170 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9732 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009020171 X-Rspamd-Queue-Id: 0AF8318140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/1/20 11:14 PM, Michal Hocko wrote: > On Wed 02-09-20 10:50:16, Li Xinhai wrote: >> Since commit cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic >> hugepages using cma"), the gigantic page would be allocated from node >> which is not the preferred node, although there are pages available from >> that node. The reason is that the nid parameter has been ignored in >> alloc_gigantic_page(). >> >> Besides, the __GFP_THISNODE also need be checked if user required to >> alloc only from the preferred node. >> >> After this patch, the preferred node is tried first before other allowed >> nodes, and don't try to allocate from other nodes if __GFP_THISNODE is >> specified. If user don't specify the preferred node, the current node >> will be used as preferred node, which makes sure consistent behavior of >> allocating gigantic and non-gigantic hugetlb page. > > Technically speaking this is still not in full sync with the allocator > semantic. E.g. cma allocator should try nodes in the node distance > order. Possible but not sure how much we really do care for those who > preallocate cma pools. Also __GFP_NOWAIT should skip CMA as that > requires mutex - or even better make alloc_cma gfp aware. Likely few > more things. > > If we care then something for a patch or two on its own and also make > the cma part a function on its own to remove the ugly ifdef. Agreed. There is plenty of room for improvement which can be done with subsequent changes. >> Fixes: cf11e85fc08cc6a4 ("mm: hugetlb: optionally allocate gigantic hugepages using cma") >> Cc: Roman Gushchin >> Cc: Mike Kravetz >> Cc: Michal Hocko >> Signed-off-by: Li Xinhai > > Acked-by: Michal Hocko Reviewed-by: Mike Kravetz -- Mike Kravetz