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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2582AC8300F for ; Thu, 29 Aug 2024 08:45:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C90D6B00BE; Thu, 29 Aug 2024 04:45:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 852B16B00C2; Thu, 29 Aug 2024 04:45:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67E236B00C0; Thu, 29 Aug 2024 04:45:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 44EB76B00B3 for ; Thu, 29 Aug 2024 04:45:12 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id AB5F280A80 for ; Thu, 29 Aug 2024 08:45:11 +0000 (UTC) X-FDA: 82504648422.13.7A8867C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id CFF771C000C for ; Thu, 29 Aug 2024 08:45:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Vebhn5nU; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724921039; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zwYKK7AMoFVBHc0427lIp+Y+u5sEYUEoBLFu6Dvvewk=; b=KhgCdX4xmfbyDj3XW/s3l5tnZXDmdqKFrY8HaOlopTRSI3geF3LTCOP5JhjzRL+ElAb6j6 247EX4Aa4mGfiX/7pY/3C9PjsvuK/WmsiHKVNlCGkB31oyO4Ado8IjPHDkJs3zKG+6/K8l BLH9GFQ8SYC7+jBvjytBwgG55HgCHJg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Vebhn5nU; spf=pass (imf21.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724921039; a=rsa-sha256; cv=none; b=qxgur0BUWoW1kck37wZWn4U0Cj+sRkpbBVtUs5fDZCq6ZPLd7l89iyGsug8aJEQCsSQLl/ VbboxKy1rjZygASF6rHTkE9a40CqvXyzXYuVdx32wU9vnoPd1xQw3FEdIZZAXY0f1EkVc6 ddH1wIi48XkAYDlyhZHOOlo7O4wQ9gI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724921109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zwYKK7AMoFVBHc0427lIp+Y+u5sEYUEoBLFu6Dvvewk=; b=Vebhn5nU20A9XhCFT1bhgra8wZByM5ywzJmnSDJeuRDMvUzOkrlxTeksOCMMYrkMT0gVOk 0HOOPKbIVjY9kw9sUs6Kp18JfxnqT3QP+tb7kugi/vypVkGFDFEtfmxnirEbaJHSeWAhQ8 gmKycn4oe8l6TyBlCzQq3S76W703wL8= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-i3eh0m0lOnKWNUoudfTD2g-1; Thu, 29 Aug 2024 04:45:01 -0400 X-MC-Unique: i3eh0m0lOnKWNUoudfTD2g-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E2EF1955BF8; Thu, 29 Aug 2024 08:44:59 +0000 (UTC) Received: from localhost (unknown [10.72.112.42]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AD08819560AA; Thu, 29 Aug 2024 08:44:57 +0000 (UTC) Date: Thu, 29 Aug 2024 16:44:51 +0800 From: Baoquan He To: Uladzislau Rezki Cc: linux-mm@kvack.org, Andrew Morton , LKML , Christoph Hellwig , Michal Hocko , Oleksiy Avramchenko Subject: Re: [PATCH] mm: vmalloc: Refactor vm_area_alloc_pages() function Message-ID: References: <20240827190916.34242-1-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Stat-Signature: mmx9kxmbdqq69enr44x75axmpbjpgwd7 X-Rspam-User: X-Rspamd-Queue-Id: CFF771C000C X-Rspamd-Server: rspam02 X-HE-Tag: 1724921109-405020 X-HE-Meta: U2FsdGVkX18afWan+hDdge68onTvzYXqa1Gwrx96QbPbgMcZAd9GHOTDGaeXtGmG0tqljJY1a6Ne/1+tV75hP8GkgUKcm2Jf+TmQJsX69z4s2Z6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dONAoPUjZ2ItbQAC57pMdzDVCXfYrfOCoRZylHE1JCwGunThwDXh6ia/QXAJ1bdSglUV8ogoHtkY1SXhUViEUxa+ftBnbtsj3Q8gskGGQdqKzsz6N4lm8chDxa1FyfCoOYOyHsy/px6UAm2HXbe5+rfdUSh24JFnZBw40MavTrHJN3b5chIwdf2ZEVdAA28TW6gtyhyFQPq6ef7c5VD1Md0RR48W2mqawqQaYlo= 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: List-Subscribe: List-Unsubscribe: On 08/29/24 at 10:12am, Uladzislau Rezki wrote: > On Thu, Aug 29, 2024 at 11:48:32AM +0800, Baoquan He wrote: > > On 08/27/24 at 09:09pm, Uladzislau Rezki (Sony) wrote: > > > The aim is to simplify and making the vm_area_alloc_pages() > > > function less confusing as it became more clogged nowadays: > > > > > > - eliminate a "bulk_gfp" variable and do not overwrite a gfp > > > flag for bulk allocator; > > > - drop __GFP_NOFAIL flag for high-order-page requests on upper > > > layer. It becomes less spread between levels when it comes to > > > __GFP_NOFAIL allocations; > > > - add a comment about a fallback path if high-order attempt is > > > unsuccessful because for such cases __GFP_NOFAIL is dropped; > > > - fix a typo in a commit message. > > > > > > Signed-off-by: Uladzislau Rezki (Sony) > > > --- > > > mm/vmalloc.c | 37 +++++++++++++++++-------------------- > > > 1 file changed, 17 insertions(+), 20 deletions(-) > > > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > > index 3f9b6bd707d2..57862865e808 100644 > > > --- a/mm/vmalloc.c > > > +++ b/mm/vmalloc.c > > > @@ -3531,8 +3531,6 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > unsigned int order, unsigned int nr_pages, struct page **pages) > > > { > > > unsigned int nr_allocated = 0; > > > - gfp_t alloc_gfp = gfp; > > > - bool nofail = gfp & __GFP_NOFAIL; > > > struct page *page; > > > int i; > > > > > > @@ -3543,9 +3541,6 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > * more permissive. > > > */ > > > if (!order) { > > > - /* bulk allocator doesn't support nofail req. officially */ > > > - gfp_t bulk_gfp = gfp & ~__GFP_NOFAIL; > > > - > > > while (nr_allocated < nr_pages) { > > > unsigned int nr, nr_pages_request; > > > > > > @@ -3563,12 +3558,11 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > * but mempolicy wants to alloc memory by interleaving. > > > */ > > > if (IS_ENABLED(CONFIG_NUMA) && nid == NUMA_NO_NODE) > > > - nr = alloc_pages_bulk_array_mempolicy_noprof(bulk_gfp, > > > + nr = alloc_pages_bulk_array_mempolicy_noprof(gfp, > > > nr_pages_request, > > > pages + nr_allocated); > > > - > > > else > > > - nr = alloc_pages_bulk_array_node_noprof(bulk_gfp, nid, > > > + nr = alloc_pages_bulk_array_node_noprof(gfp, nid, > > > nr_pages_request, > > > pages + nr_allocated); > > > > > > @@ -3582,30 +3576,24 @@ vm_area_alloc_pages(gfp_t gfp, int nid, > > > if (nr != nr_pages_request) > > > break; > > > } > > > - } else if (gfp & __GFP_NOFAIL) { > > > - /* > > > - * Higher order nofail allocations are really expensive and > > > - * potentially dangerous (pre-mature OOM, disruptive reclaim > > > - * and compaction etc. > > > - */ > > > - alloc_gfp &= ~__GFP_NOFAIL; > > > } > > > > > > /* High-order pages or fallback path if "bulk" fails. */ > > > while (nr_allocated < nr_pages) { > > > - if (!nofail && fatal_signal_pending(current)) > > > + if (!(gfp & __GFP_NOFAIL) && fatal_signal_pending(current)) > > > break; > > > > > > if (nid == NUMA_NO_NODE) > > > - page = alloc_pages_noprof(alloc_gfp, order); > > > + page = alloc_pages_noprof(gfp, order); > > > else > > > - page = alloc_pages_node_noprof(nid, alloc_gfp, order); > > > + page = alloc_pages_node_noprof(nid, gfp, order); > > > + > > > if (unlikely(!page)) > > > break; > > > > > > /* > > > * Higher order allocations must be able to be treated as > > > - * indepdenent small pages by callers (as they can with > > > + * independent small pages by callers (as they can with > > > * small-page vmallocs). Some drivers do their own refcounting > > > * on vmalloc_to_page() pages, some use page->mapping, > > > * page->lru, etc. > > > @@ -3666,7 +3654,16 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, > > > set_vm_area_page_order(area, page_shift - PAGE_SHIFT); > > > page_order = vm_area_page_order(area); > > > > > > - area->nr_pages = vm_area_alloc_pages(gfp_mask | __GFP_NOWARN, > > > + /* > > > + * Higher order nofail allocations are really expensive and > > ~~~~~~~~~~~~ > > Seems we use both higher-order and high-order to describe the > > non 0-order pages in many places. I personally would take high-order, > > higher-order seems to be a little confusing because it's not explicit > > what is compared with and lower. > > > > Surely this is not an issue to this patch, I see a lot of 'higher order' > > in kernel codes. > > > I agree. It sounds like hard to figure out the difference between both. > Are you willing send the patch? If not, i can send it out :) I am fine, please go ahead.