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 448EDE77188 for ; Fri, 3 Jan 2025 14:47:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C33E06B0083; Fri, 3 Jan 2025 09:47:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE3776B0085; Fri, 3 Jan 2025 09:47:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AABA06B0088; Fri, 3 Jan 2025 09:47:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8D2C56B0083 for ; Fri, 3 Jan 2025 09:47:05 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 195FE1407DA for ; Fri, 3 Jan 2025 14:47:05 +0000 (UTC) X-FDA: 82966415910.27.70360E3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 1D5AD20015 for ; Fri, 3 Jan 2025 14:46:12 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iFwoXmx9; spf=pass (imf13.hostedemail.com: domain of luizcap@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=luizcap@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=1735915599; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7ugLikuePf+W66VlwF+hcqdH51iUEo4PuTVkmD6aZBk=; b=wJxUeTExZQlnob8QtdtZ+Gb2rpuiuMfoDMNL8vRsYakMphk41fIAExmxU1xo2+zpThwI2T TYaPg+SbKYWQV0WLYKz7JiiujtFY8cl2GxDSnIg6xyhH9nKVyygJUrxNG27t4kI/vsKlmx nb7QBNE+hRCeg9okqlfjuHOCcuzg1Ac= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iFwoXmx9; spf=pass (imf13.hostedemail.com: domain of luizcap@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=luizcap@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735915599; a=rsa-sha256; cv=none; b=3a6gvtHgINDicIvFVInKMSsqSoKBWLX4iqfejQiasBkliwcnyPfuVLcfBWRraXpjDjsFzc iLHNhivZTuF1f9yLznAGa3r+GzqrSFumOZtvXaV8tX+mrYaDBE5Alj6P7ISqF7psCiIEZE q8JP6fyZpkvjmVyeZVRX1lqPSoXfm8Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735915621; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7ugLikuePf+W66VlwF+hcqdH51iUEo4PuTVkmD6aZBk=; b=iFwoXmx9SmnAmQdAWN4W7XqcKEWFEsY5pp8+J0rzFkSwWBz1w5yFHWH4ctnu+r5yQPM7ps Linek4/lAJ/DS5dEKNOQjE3unsHSmqAqxNp8ygyk04J/dS5CjQD+YPKRog5RKxwL3ZwAf/ rDtDShbaHXNJ0Z+T25u0KCDhhGaMVZ4= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-1tw__WDjPL2Db_FM9kYihQ-1; Fri, 03 Jan 2025 09:47:01 -0500 X-MC-Unique: 1tw__WDjPL2Db_FM9kYihQ-1 X-Mimecast-MFC-AGG-ID: 1tw__WDjPL2Db_FM9kYihQ Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7b6e852eeabso1866031885a.0 for ; Fri, 03 Jan 2025 06:47:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735915620; x=1736520420; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7ugLikuePf+W66VlwF+hcqdH51iUEo4PuTVkmD6aZBk=; b=Geg+kMIR4fLK9+EgGVyqsHFTohwqqyaGhU5bU2s219ERp3T42se3aC+eOvlE8jmKrH 0of3UswFH/EErTvwNbRtVZolZDpnBWp0tJxK3dIt/MqHLEb9rumidbtLnM2L2Ggoq4ib 10JTk2XnN1fA8g0P6+nec8q7NFkF+TnLPNKoFDkxa1LCTGBCd+4bYLiJI5z9WlbE2McE Rp/lfG7p4qXp3aDXuNZ6GlI9kwBJy5iAc0oDoyIsBYcby5CR1p6sbEaas6eSo0rcga0W lCJJbAuMceflEpiDNkCfKmcWJLM5KNKvfHYl9J5qj8Jx4IHNQ0WuyDEQBFahXVkW6HJW D2aQ== X-Gm-Message-State: AOJu0YytQpfZYL3M2eu0yJflOf5OypYKNtzUAowg6qeJuSaRzO1ncZ7F QD8hyHv+Rgy3by4Ylb3JhlEZTevoaDRzOsEerWwJe1gbTfzLHnxPNmX1VX+g4p18cd868qcUJrf 7p9KFC49W/Rcf+r7vJ7927zKz2OxNi7ikbjvHstnRNn8BFl38 X-Gm-Gg: ASbGncvbd6N0oC/lYI9AXQUVXP96j9hlvmeDXLQfgZbkmHVcb2Oz98qlYD1g70aTdDO GgTk/rGsmvyfoAoHqTwKYuqE/Xf2hk/OnDjCZf+GMcmFA3Qrngf9hm51UOpiekRtyX/gkEtCcfm jAFBq2fcPyBcEDIvHM960EjiTlg5hG9mb39Nx9xct6l6pZh+hLLAd7UIX8Rs8R5k53V5EjtF6/x 4OG7SAmJjw6HWozLOS7ib9VYXYOYk3UyLEhNDrOigxMFu/CVwK1HjhGe0/3QOXP+rJYRTvOr2qK v1wUsf3y7D4amJVOEgz0TEsu6zGFgLLCwXVZQkhTHQ== X-Received: by 2002:a05:620a:4807:b0:7b6:d611:ce82 with SMTP id af79cd13be357-7b9ba83580dmr7444757185a.59.1735915619800; Fri, 03 Jan 2025 06:46:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBSq0s088Q5EscUvHxlxZ1a9kvCLX7Le1q6E7WC2oWr2U1JvGLdvRAuVcgUhhOwb3tZuXENw== X-Received: by 2002:a05:620a:4807:b0:7b6:d611:ce82 with SMTP id af79cd13be357-7b9ba83580dmr7444739685a.59.1735915617727; Fri, 03 Jan 2025 06:46:57 -0800 (PST) Received: from [192.168.2.110] (bras-base-aylmpq0104w-grc-14-70-52-22-87.dsl.bell.ca. [70.52.22.87]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b9ac480ea7sm1275469185a.94.2025.01.03.06.46.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Jan 2025 06:46:57 -0800 (PST) Message-ID: Date: Fri, 3 Jan 2025 09:46:56 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] mm: alloc_pages_bulk_noprof: drop page_list argument To: Mel Gorman , Yunsheng Lin Cc: linux-mm@kvack.org, willy@infradead.org, david@redhat.com, linux-kernel@vger.kernel.org, lcapitulino@gmail.com References: <6b56af9b-2670-4a15-84e8-314443ae590c@huawei.com> From: Luiz Capitulino In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bi9IRERYwlCH7Cx9QEYXVkuP00nZVgg0OXySSGww18I_1735915620 X-Mimecast-Originator: redhat.com Content-Language: en-US, en-CA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 1D5AD20015 X-Stat-Signature: 4fmdku9qskdt5iuqesbq4p36ufacdry7 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1735915572-147791 X-HE-Meta: U2FsdGVkX19lUFeVpmReubgYxOPn/mVk0NSB0ciSKj+pWi7KUAXMwWn3V9027K8n9ZJL0Yt7+MaBlfB1F8nwr4keV28hzevAdbkoxjdB39xfHyuIjVlM/e9DWnr5tDCtjnkpkPOW1G0ame4bj6PO4mXDbwBOeTaF6FTz1VUOL8qwK+Ww2XA934eVleDuFoaz6Yk82c2qKpie0qZ2x59bxi2dk8zpQ8AE+KVNnsYWaadAKCExLFg51yzZWgGifz+OCe91PbNb/JF0W8Dgwmron8a1GYUzbGlpxeJGG57dEy+Dd2toIzv3JfigaQryYzHZESEY/zPvc4KVOlAuEXCh+cg9OLkzzpBjAhZd3Dywn2zmvvGZBW1tpkWzWUfFIBR6divjXCke2r5dH8XDqhQe49YsloXjJjS7RFWIUqA08yz4vY2V4y2X6WF3JhUDheNOlSnQ0vnEJ/pycgpzQUFr3tKOka2xb5ZzvHOd6fPyIb9SVXyBMyor+DEPUmBBZ4696uLaN0A+UDdNDXb0zDhEZRWGqLgQUIgaq7ULY4bQ57g3bjZmgKBlHqQqMU2P+08WsX337RRqKYNiFkmEI/pYXV46KYqePPY3jxtYiaeREnW0nGldccK1EN72kb5v9TFDw9Vau6Pic2+8nAXlo41CqdBc7bcs17b25vqHNHQuxIfmaHFvEbt2GZkRFz95+8FmdHfQ6yf5YJntcQ7auQVjn0Xs3EJLfp2qDE0tuY/aQt1URo4mgjX/Pzh6cNFeJTVnz3u1tZ0wfRyJq5+SsKjHKwsv1o1nkLdLgBaf5RBgvslltlrJi6FigKhPN6M7h26vPTPp3/SWNFF/DdrjH6m9y+Mxp4+6xMZrjHpzKJr6EvlQXP6r4q6GONUl1EJW6xdF16covkDLwbdZ35mwApjMbTHuHoWPXersMFMs5RR0elVHK5/c4/zE4mYTozGh3bUcsZprMbl2L4kNllyI5HS sY/QdUj+ jwIFCiL+2nXenl1OiQyLEl4NdzODi/U0O7qXiVTzISyBhLb+MoFbE30dQXoGlF/gYyjCqNhCaB9Riqe0ueHkJeOUAmoGxnhMXHcGesJcMIHCfzl+6eUD2uJyFJYsHyWApahm6KEJgMD1o+BXbuKZuv/S4YdNf5URHlxRReKwqgVj9fhoE+xA0TeG2Eds0G+TvvAM3hOLKVgU3JYGhyp8Bx82Vz7zGoy/VDzsNZsnvTVPhnpyNX9SxKOBLOpqWwcrhYvnTyYFuTiM2SQytV5eJuZrW8SRMv2Hmauf9zA+FIdkORiUR2Wws2s6gv2awTRPBudM/hkYTPbfBZhpLj+luesousCLaq7UGs9Dpqu4OVCguAtmXFeYpfLpwnEMs3bJUyh4d2Mr1x2WyGRjdtJf6m2NrYmrRoFRv0IN4odWglJTJ/onefZBILnUb6383/Ds6j/9cJY6iJVGA7LQoUdLtqMjzhEpcQEdiVFZWpvB37ONfVJrAJj2xRs/ROtjsTxuoR+3x28HogEkRooLCd3nH+4PwlNcfjwbD5yVcMihEAoAIKYs= 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 2025-01-03 09:27, Mel Gorman wrote: > On Fri, Jan 03, 2025 at 07:29:30PM +0800, Yunsheng Lin wrote: >> On 2025/1/3 4:00, Mel Gorman wrote: >>> On Wed, Dec 25, 2024 at 08:36:04PM +0800, Yunsheng Lin wrote: >>>> On 2024/12/24 6:00, Luiz Capitulino wrote: >>>> >>>>> /* >>>>> - * __alloc_pages_bulk - Allocate a number of order-0 pages to a list or array >>>>> + * __alloc_pages_bulk - Allocate a number of order-0 pages to an array >>>>> * @gfp: GFP flags for the allocation >>>>> * @preferred_nid: The preferred NUMA node ID to allocate from >>>>> * @nodemask: Set of nodes to allocate from, may be NULL >>>>> - * @nr_pages: The number of pages desired on the list or array >>>>> - * @page_list: Optional list to store the allocated pages >>>>> - * @page_array: Optional array to store the pages >>>>> + * @nr_pages: The number of pages desired in the array >>>>> + * @page_array: Array to store the pages >>>>> * >>>>> * This is a batched version of the page allocator that attempts to >>>>> - * allocate nr_pages quickly. Pages are added to page_list if page_list >>>>> - * is not NULL, otherwise it is assumed that the page_array is valid. >>>>> + * allocate nr_pages quickly. Pages are added to the page_array. >>>>> * >>>>> - * For lists, nr_pages is the number of pages that should be allocated. >>>>> - * >>>>> - * For arrays, only NULL elements are populated with pages and nr_pages >>>>> + * Note that only NULL elements are populated with pages and nr_pages >>>> >>>> It is not really related to this patch, but while we are at this, the above >>>> seems like an odd behavior. By roughly looking at all the callers of that >>>> API, it seems like only the below callers rely on that? >>>> fs/erofs/zutil.c: z_erofs_gbuf_growsize() >>>> fs/xfs/xfs_buf.c: xfs_buf_alloc_pages() >>>> >>>> It seems it is quite straight forward to change the above callers to not >>>> rely on the above behavior, and we might be able to avoid more checking >>>> by removing the above behavior? >>>> >>> >>> It was implemented that way for an early user, net/sunrpc/svc_xprt.c. >>> The behaviour removes a burden from the caller to track the number of >>> populated elements and then pass the exact number of pages that must be >>> allocated. If the API does not handle that detail, each caller needs >>> similar state tracking implementations. As the overhead is going to be >>> the same whether the API implements it once or each caller implements >>> there own, it is simplier if there is just one implementation. >> >> It seems it is quite straight forward to change the above use case to >> not rely on that by something like below? >> >> diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c >> index 43c57124de52..52800bfddc86 100644 >> --- a/net/sunrpc/svc_xprt.c >> +++ b/net/sunrpc/svc_xprt.c >> @@ -670,19 +670,21 @@ static bool svc_alloc_arg(struct svc_rqst *rqstp) >> pages = RPCSVC_MAXPAGES; >> } >> >> - for (filled = 0; filled < pages; filled = ret) { >> - ret = alloc_pages_bulk_array(GFP_KERNEL, pages, >> - rqstp->rq_pages); >> - if (ret > filled) >> + for (filled = 0; filled < pages;) { >> + ret = alloc_pages_bulk_array(GFP_KERNEL, pages - filled, >> + rqstp->rq_pages + filled); >> + if (ret) { >> + filled += ret; >> /* Made progress, don't sleep yet */ >> continue; >> + } >> >> set_current_state(TASK_IDLE); >> if (svc_thread_should_stop(rqstp)) { >> set_current_state(TASK_RUNNING); >> return false; >> } >> - trace_svc_alloc_arg_err(pages, ret); >> + trace_svc_alloc_arg_err(pages, filled); >> memalloc_retry_wait(GFP_KERNEL); >> } >> rqstp->rq_page_end = &rqstp->rq_pages[pages]; >> > > The API implementation would also need to change to make this work as the > return value is a number of pages that are on the array, not the number of > new pages allocated. Even if fixed, it still moves cost and complexity to > the caller and the API is harder to use and easier to make mistakes. That > shift in responsibility and the maintenance burden would need to be > justified. While it is possible to use wrappers to allow callers to decide > whether to manage the tracking or let the API handle it, the requirement > then is to show that there is a performance gain for a common use case. I agree with all your points, but I think there's value in simplifying alloc_pages_bulk_noprof() if the wrappers turn out not be complex or difficult to use. If all users of this case always fill the array sequentially, then maybe we could just have a wrapper that scans the array first (this is the first loop in alloc_pages_bulk_noprof()) or maybe callers could keep track of 'filled' (via a pointer or macro usage). But this is just brainstorming, we'd need to see the resulting code to know if it works and makes sense. > This is outside the scope of a serise that removes the page_list > argument. Even if a series was proposed to shift responsibility to the > caller, I would not expect it to be submitted with a page_list removal. Yes, absolutely.