From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9D5E125D6 for ; Thu, 2 Jan 2025 16:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735835946; cv=none; b=dns4vSn23EI46TO5FSz60E8dI8kh1G7Go+kQekDV910X3drlV6tMtk8HGomFomLttJHNlQR2XCk8Wn5DBQ4M78GDmshR+Z/ZaQUnxRJLu+M4k6dARMFb80+PR9B4ZLQ0JRZa3fQJ1JPlRvL+7RSLsH8IhyG/mZftNt+hPYhkjVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735835946; c=relaxed/simple; bh=mSnRnyGFLiMp8SuzJ3hkQj2kbx+5/2lpsKSU7eOg4+A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cT25dQzV3Ifr1blANomtCcUMRl7B3X0pKJF+f+r504APLs9xKgBvFEj824kUGmltlkGEeCpjxKZxlrVc0rya/5mocHuPPyZpamRVpPJ5zkkIYDkwzEYHJlisEd+/cOoOwwC07k6f3lKdZBIPrq0xEwzOBatoWKB3GBZ5YdIdkRw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RtnSelV8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RtnSelV8" 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-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-mX15qi2uNLO9ZyjejY-4Og-1; Thu, 02 Jan 2025 11:39:01 -0500 X-MC-Unique: mX15qi2uNLO9ZyjejY-4Og-1 X-Mimecast-MFC-AGG-ID: mX15qi2uNLO9ZyjejY-4Og Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7b6e7f07332so5195585a.1 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=hiXHOLjv58d+BIhjOQevRvFHK1bUkOMsttK3pE7Q1uiqfVWuq1dlGNbPSyUudNBfNf BtAtrRTtWRTJFNhezV93q46jNJDuWlqrYqhpQqxSvvYH9Ajug6Y3SCrGCHwI9xoh/+zV AxJDMyoxP1ChHsE0nRtB2CIppIX1Nrko8i5t2F9xWSaEtR7yIzBvQUCkYhe0FJYfVjT+ /6/9bLBznnQL+xswKtCtGBPzVgzZbh+EqqaGcCqsRrYF6C4+9tqBfSJAS9iGEVCeJETU BIRswVTazdYvyDRpxZ6UNVykpX5EwTdyziyZHD5Pe3v3zwaHaYJtSoffjsR0caRmrPpx Hjbg== X-Forwarded-Encrypted: i=1; AJvYcCV7gRzsuqN4bzX5XTG/GPABWDnQVLr78lN0j9I3SiqF4m4k9VMptKfjnaYBM9A41SGYLa7EAoGrtRWKUd4=@vger.kernel.org X-Gm-Message-State: AOJu0YwWkvwfkPFyx1exxZfwdA47/eNh2tRXZlQ/Y5ICYjh5mpuy1deE xTpiBsHNIZ3hoKye7Iin5nBX+3yBjID7uUTqEw98KDMCDW7SvCu8R0wFHi0KcWlmZ6R4K97FZvb YIqCa3VpK0rYME536w26eCqCF88ttJD6yaahCwfplIQeYK1Pcx0Cwupwi7iM11w== X-Gm-Gg: ASbGncvIPaJ+q/wMEs7ghmm+pI6lfcWpwsrSsbqNfRPYSzZFYBMzXe97U0MCr6orWPe U6M153TCUUIY+cK4uMgBE0FDN2wqA6XEABH6LJ565YIw9OokVkBgvAzLkdrTGJi+XswHZMybrUO hSdUMMDsVrGojDv5FTJycrK2+iXdFLmaKciZwH93AuMyan5FNPsllrDphnUEU+qZZu8QK0rmbHR XmW4pAuPVVF44AVlm/oXB2AV2++iQ1UrWHrUGm4oqsBJ7r/AS5gVmcv X-Received: by 2002:a05:620a:2904:b0:7b6:6365:1b72 with SMTP id af79cd13be357-7b9ba6fdafdmr7130019185a.3.1735835940980; 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: Content-Language: en-US, en-CA From: Luiz Capitulino In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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; >> } > >