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 54512E77188 for ; Thu, 2 Jan 2025 16:39:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62DF66B00D2; Thu, 2 Jan 2025 11:39:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DD0C6B00D4; Thu, 2 Jan 2025 11:39:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47D7C6B00D5; Thu, 2 Jan 2025 11:39:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 26C446B00D2 for ; Thu, 2 Jan 2025 11:39:06 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C48BF1A0139 for ; Thu, 2 Jan 2025 16:39:05 +0000 (UTC) X-FDA: 82963070316.05.8404549 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id C8B6F4001B for ; Thu, 2 Jan 2025 16:38:24 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RtnSelV8; spf=pass (imf17.hostedemail.com: domain of luizcap@redhat.com designates 170.10.133.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=1735835896; a=rsa-sha256; cv=none; b=A3NA4hZpcYAUEpVnrqU7Bgw4xyJCVYzrRZCX3LdnEttUFBkEYWPwHNhGJ4QNukczVsvjkd G9boGNdqBCXqfttxiD55WdUN+GkM45mbtT64syH1iJoHpPRikJlDmCTGlHzLDVnI5jpZgQ 1fwXZgESRJyJFxW0tsLyS+c8RTTg3fo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RtnSelV8; spf=pass (imf17.hostedemail.com: domain of luizcap@redhat.com designates 170.10.133.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=1735835896; 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=mbV1KNVRdnxVXo06WJr9AofusMPlY05MupkeMH4VEFE=; b=STU07PmyOUEjEYZyTRFwP4Y/1Q9jsbp6Jp7y+MbVtt3Za/h09py/Zghd9FdaP3quyw7IGp pk8zaNtS1BzMPhmdrmOw6eQlPbTtT8T/tXXWYdR5j6KRQ11LsqTM4FkxTY1rATVZNfDBmz LdSu6wj/EDj0DsRxpdAYg6+QrPBqVho= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735835942; 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=mbV1KNVRdnxVXo06WJr9AofusMPlY05MupkeMH4VEFE=; b=RtnSelV87O/E6x12gLGCoXDv9zVU922RARgEURzTRGwNu26H4AsSA/PKb9nkvQM0QXAsyS lIWX33TeoUZmU/qKYMqc+/aZ0jbMbT/9J9oaMiRy8rPiamF+dhxF+hf+DKb2CaiyQ0nLdI JEy2/gT1UbbYN1IZu+4BEMAGPnr4YiA= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-bs8Frv5pO9K4TS-cisWn1A-1; Thu, 02 Jan 2025 11:39:01 -0500 X-MC-Unique: bs8Frv5pO9K4TS-cisWn1A-1 X-Mimecast-MFC-AGG-ID: bs8Frv5pO9K4TS-cisWn1A Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7b6c51069f5so359594985a.3 for ; Thu, 02 Jan 2025 08:39:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735835941; x=1736440741; 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=mbV1KNVRdnxVXo06WJr9AofusMPlY05MupkeMH4VEFE=; b=H2Ktg6/4yojeOVlnFCL29qhVb//mw4fjOjXKgIdmQiw9C6QI68bC2/+YXGYUJZXBBS lV8iTcGrnLg/VOrouYcYkOAbn1tAPLl8JhdR/qo8opPaDDd9shNSOW4KlZo5Ulz2JhiU Mj55k+0uHfbrc1sO747GcKEkWGVmOT9c76rSez/yWOQz6J58DLiBfO5uju/EAUAvXsnL oiov7TSfZHIGtl6yG8onrcKs12zRiKrr0Kit07rPocs4yRM1K3UU15V2JVNuXdPGYAhk 2A+Ihs85B1r4nf1FZDAasDXXAty3lRnj/BFXIq/gNPmItWTnHAx89QuFWGmvrw/zeNqw Vq/g== X-Forwarded-Encrypted: i=1; AJvYcCXvFSyHdqJBoTF3W7akrssU/+oGavFMMqIx49uQG9q+FmjS+2xqDx2eTQgxJuvEq75zuXxzGGDIzQ==@kvack.org X-Gm-Message-State: AOJu0YzYdZZ6aIIheBfjHlWrcAijPsOqFV+FRD4GbBDrZFQ/OyfHTDVW U3e9oWwfbETbSQlkgE5udY9yQCFxcYXMLg4k5brKMoLWVjV0T9hpfipy64XMCqMPunAPHbABILj /Hl6Omt6WBaNJmKGpGErhEOYUOXbInnEizWvgL//JcyNoGRGs X-Gm-Gg: ASbGncu3n79c6En49J4zO/RPoNrEcOe4e4pRgs60eowQGjy8qRyhjyDOte8pZTdAFSz vEWCaVNfdyqTk/Es+JkKAoxEqF4lwLPmApu97FBkuRRZgkMFWbQFTLGnqa+KTFznU/cFK6Wa7mD vdBX9Oq7ek+2blHjEspT10EIRmSzwQr80ap/hjXkaHdP8iJkyx7sjRHuqWqP3didNSNVeWUZ4kc YNE3QsoMKQdHQipD7B/aHHzjrdeGNM7Rdk+rh+kWyfzHyszd7nqMj2e X-Received: by 2002:a05:620a:2904:b0:7b6:6365:1b72 with SMTP id af79cd13be357-7b9ba6fdafdmr7130019285a.3.1735835940981; Thu, 02 Jan 2025 08:39:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMDTrhXSh+9jT3XuIBrAeU4PHMjx1kcO0PKtNBFp1Bv4kthGdtKoRO0l0vmnZpWHlpXuhXBg== X-Received: by 2002:a05:620a:2904:b0:7b6:6365:1b72 with SMTP id af79cd13be357-7b9ba6fdafdmr7130016285a.3.1735835940676; Thu, 02 Jan 2025 08:39:00 -0800 (PST) Received: from [192.168.2.110] ([70.52.22.87]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b9ac4cd55dsm1200047485a.116.2025.01.02.08.38.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jan 2025 08:39:00 -0800 (PST) Message-ID: Date: Thu, 2 Jan 2025 11:38:49 -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: Yunsheng Lin , linux-mm@kvack.org, mgorman@techsingularity.net, willy@infradead.org Cc: david@redhat.com, linux-kernel@vger.kernel.org, lcapitulino@gmail.com References: From: Luiz Capitulino In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: krhQcN0S46WrOwsKYLD_Z6akJL3b7XJ3XujXsELChzQ_1735835941 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: C8B6F4001B X-Stat-Signature: rjp117rwjtuc7371ytob5naahc5iuzan X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1735835904-797993 X-HE-Meta: U2FsdGVkX1/juGVff+KKr55iOcx7y/FXcVeKTxtAv77OBpjULciSC15xpflIZ1zj+2SApcGCT7ig8kUApkiA62Mwc5NFISaPJNHeYz957XeyBu/7KdqbOxXSVgqEx1FBoBhXRczOb8EpTOKyrRD5wVZmLyXNqLqX4RGDPGb/BnJ1Ha+bQOayhMvQVhxC1uOwuQ6Z/ly61+VdiAQvVEKSTHuZnWgDLnW7w5u7uJt3cOzDFM7rCDuzkEDrGv8Q++rTq1Mzy0TOtsUXg0h7ck25Mzobte3hmg37M0Kwql6WleU6ol8FUwjOcu77lQmJ1STpSJWAPFpvPiumfe2jWIEEFcLNFoTR6ztkDAswRvGqQY9N6JQK7trln+b+5Uh/cOF81MIVUpDFqTkqDIcKgPbQqGJAo+xeAN7jL4VB39Rs0MDn/dHCgxhFfVASShmzJtaJhp7u8ai1T/4iOXjHGuym21RZdq4RDKEa4q/Pmw2pl7GYUh6bhGLOVKDF0cccAE5vt50ktdSZcHCbfNAL1ir8LpRwS6STDIL0e5UIY5PGAYZc/lehOXQ7sDw6YctvbilZ1+c7dqztVAZ721LFTOyMILi9HeIyY8900zJ9dZOpm7kk2gQVGhnEHmDneGFjUOjXS1BezcuqgScbVsfqabfgAUDdwsaCkfzjZlKn4Yuxv+xfmZ0S+0o7wfWrhpbJ1k8pKWWbvAvX/wGP/pAxqCw8LtPuB7OWKWkBOUZhcz6jLg5XPBZPiCo9k9YKctxeVLiPHbGtDVzbSqt9YVclRPjftVWajzwzck6pJRfjHYy8aQvCa3B2yRTDwN6qA4Rb/HJ/VWAsH9jJjqxXvB6+ZSUJGs7g9jbJUUyKqPCY2KHEldrQzGHcHQE/fnlX3o53Ibr0xopwcSjEhckrxLLsueqcFRczEC8kIVqo5JefK9Umeiy/d5BV4RSFJaHDjAMaYzpLOB9z90+ZCzCqqg22rYL CKmUMRxb 1i+pYmwOcSdvcH3HR8tsuAcovQqE3rYHDi81MLF4CMPQz9XrIJMzMCvTvv/8/wwZRv57deesVliuCCbx9n3QrVxNqfooDSavu9fJHzvXYUtv8p679QstipS9H+1tdWwV54kOerfuYwceoYt3m/4hNqkK5cjf074XwaV81zQpWv1zFn/1QBWi/VaTMc2km086vJKAEqRuFvz5SVvSYard8YVRpIrwNlpUjs2qgOvI3on624iGULzomxEem+rejUMajw3QjbhuagNRfHyPCje2rTxwmlZQDuBv8bIsaUgGhljfYJ6zNZIEX0eHMQB4xCfE9vG5waPWwF49dT+iBGeLv3hJUBArXnIWah1MWaCwgD0ucXzg3MqzPUAiKC4d5aMwxqaCoijhdet51ue5bgX9rWzN254FbRRH2oB2RHXgOVQw8seg= 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 2024-12-25 07:36, 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? Hi Yunsheng, Assuming the use-case is valid, I think we might want to keep common code in the API vs. duplicating it in callers? In any case, even if we decide to go for your suggestion, I'd prefer not to grow the scope of this series since this could delay its inclusion. Dropping the list-API (and dead code) is actually important so IMHO it should go in first. PS: Sorry for the delay in my response. - Luiz > >> * is the maximum number of pages that will be stored in the array. >> * >> - * Returns the number of pages on the list or array. >> + * Returns the number of pages in the array. >> */ >> unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, >> nodemask_t *nodemask, int nr_pages, >> - struct list_head *page_list, >> struct page **page_array) >> { >> struct page *page; >> @@ -4570,7 +4565,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, >> * Skip populated array elements to determine if any pages need >> * to be allocated before disabling IRQs. >> */ >> - while (page_array && nr_populated < nr_pages && page_array[nr_populated]) >> + while (nr_populated < nr_pages && page_array[nr_populated]) >> nr_populated++; > > The above might be avoided as mentioned above. > >> >> /* No pages requested? */ >> @@ -4578,7 +4573,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, >> goto out; >> >> /* Already populated array? */ >> - if (unlikely(page_array && nr_pages - nr_populated == 0)) >> + if (unlikely(nr_pages - nr_populated == 0)) >> goto out; >> >> /* Bulk allocator does not support memcg accounting. */ >> @@ -4660,7 +4655,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid, >> while (nr_populated < nr_pages) { >> >> /* Skip existing pages */ >> - if (page_array && page_array[nr_populated]) { >> + if (page_array[nr_populated]) { > > Similar here. > >> nr_populated++; >> continue; >> } > >