From patchwork Fri Oct 8 16:19:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 12545689 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B323DC43219 for ; Fri, 8 Oct 2021 16:19:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 620396101E for ; Fri, 8 Oct 2021 16:19:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 620396101E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C1CAD6B0073; Fri, 8 Oct 2021 12:19:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA6146B0074; Fri, 8 Oct 2021 12:19:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6E3B6B0075; Fri, 8 Oct 2021 12:19:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id 8C8A46B0073 for ; Fri, 8 Oct 2021 12:19:39 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3D1462CFF7 for ; Fri, 8 Oct 2021 16:19:39 +0000 (UTC) X-FDA: 78673780878.03.D801DF9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id E673030007B2 for ; Fri, 8 Oct 2021 16:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633709978; 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=sKT1idpTNkVhaBOIkuTT61/rDCOAntRvXZQwZuQU3No=; b=c25hZyvPuIxLI3rVprL+xVUCUmn8tKTL4hscjt3k5fc3Y/cKPry38v75OjURhgDDq8Qqcc iZmoNiGfcla0H6wkZb+qR8vtUWI7Ds/tYjJGhSQ19BHkl4oUbXkaEcz3QduHT55WnXp3hP WarZhvHM+MigrRsA+CU9buGpBJr+shM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-604-6_8SoMImMDidC4cOiJBJbg-1; Fri, 08 Oct 2021 12:19:35 -0400 X-MC-Unique: 6_8SoMImMDidC4cOiJBJbg-1 Received: by mail-wr1-f69.google.com with SMTP id e12-20020a056000178c00b001606927de88so7701843wrg.10 for ; Fri, 08 Oct 2021 09:19:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sKT1idpTNkVhaBOIkuTT61/rDCOAntRvXZQwZuQU3No=; b=LSMoxHSxjSPUCF6a4ozG1Y49rSS6oQAY/mMbCPYp9Fn8ZSeD2+Qqi07e2BF09Wj/MI AROdeKB/kxBq+eiUPRh7Z07SIEWoVXVn2PQJzzTgjNiuZQ7aD7pvsJpODmwB7yJ25k+2 YJlbZuC77A3pmkS24QHsaqtAR2aAri02sWLg1ZKBTkBrTm4PKR+yfUBJijo3S/LwNFUn GtvH8jQuR8xHr+XL8Yv4FK0W3QbtU02DVCrjARnE6b7pdO9+X7t7sQykQklhCk1Q5G4O a1FamILF8OMFSiw6vVlC8yDaRoxTZRPEC51sZo8qaNsIFti01RQjoZmcb2tW+egZe2yJ egrQ== X-Gm-Message-State: AOAM53081NwaNJqRQxgzc5hv3CzChiOrrKkZ64VLpgkUy2TxwTZQvYl+ DJhgasRalRntPDddPpbUu4OYQTPD4AUKpWRhYIOkhi+xZqhQ9daFhSv4n536gDD6OKZIG3BKSfE OD21w8RTcmME= X-Received: by 2002:a7b:c0da:: with SMTP id s26mr4467324wmh.58.1633709974149; Fri, 08 Oct 2021 09:19:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyajDwkhy5l3/UOB/lGC0lTJWJcdm20ijXtf9vCwLnu+uMQULK/wCDkF1fE82BbhRGEJC15RA== X-Received: by 2002:a7b:c0da:: with SMTP id s26mr4467307wmh.58.1633709973984; Fri, 08 Oct 2021 09:19:33 -0700 (PDT) Received: from vian.redhat.com ([2a0c:5a80:1d03:b900:c3d1:5974:ce92:3123]) by smtp.gmail.com with ESMTPSA id f184sm2901753wmf.22.2021.10.08.09.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 09:19:33 -0700 (PDT) From: Nicolas Saenz Julienne To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, frederic@kernel.org, tglx@linutronix.de, peterz@infradead.org, mtosatti@redhat.com, nilal@redhat.com, mgorman@suse.de, linux-rt-users@vger.kernel.org, vbabka@suse.cz, cl@linux.com, paulmck@kernel.org, ppandit@redhat.com, Nicolas Saenz Julienne Subject: [RFC 1/3] mm/page_alloc: Simplify __rmqueue_pcplist()'s arguments Date: Fri, 8 Oct 2021 18:19:20 +0200 Message-Id: <20211008161922.942459-2-nsaenzju@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008161922.942459-1-nsaenzju@redhat.com> References: <20211008161922.942459-1-nsaenzju@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: E673030007B2 X-Stat-Signature: ytsrmcz4uc47u6rha4bgfnuzpsnuzcsq Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c25hZyvP; spf=none (imf03.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=nsaenzju@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-HE-Tag: 1633709978-543836 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: Both users of __rmqueue_pcplist() use the same means to extract the right list from their per-cpu lists: calculate the index based on the page's migratetype and order. This data is already being passed to __rmqueue_pcplist(), so centralize the list extraction process inside the function. Signed-off-by: Nicolas Saenz Julienne --- mm/page_alloc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b37435c274cf..dd89933503b4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3600,11 +3600,13 @@ static inline struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order, int migratetype, unsigned int alloc_flags, - struct per_cpu_pages *pcp, - struct list_head *list) + struct per_cpu_pages *pcp) { + struct list_head *list; struct page *page; + list = &pcp->lists[order_to_pindex(migratetype, order)]; + do { if (list_empty(list)) { int batch = READ_ONCE(pcp->batch); @@ -3643,7 +3645,6 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, unsigned int alloc_flags) { struct per_cpu_pages *pcp; - struct list_head *list; struct page *page; unsigned long flags; @@ -3656,8 +3657,7 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, */ pcp = this_cpu_ptr(zone->per_cpu_pageset); pcp->free_factor >>= 1; - list = &pcp->lists[order_to_pindex(migratetype, order)]; - page = __rmqueue_pcplist(zone, order, migratetype, alloc_flags, pcp, list); + page = __rmqueue_pcplist(zone, order, migratetype, alloc_flags, pcp); local_unlock_irqrestore(&pagesets.lock, flags); if (page) { __count_zid_vm_events(PGALLOC, page_zonenum(page), 1); @@ -5202,7 +5202,6 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, struct zone *zone; struct zoneref *z; struct per_cpu_pages *pcp; - struct list_head *pcp_list; struct alloc_context ac; gfp_t alloc_gfp; unsigned int alloc_flags = ALLOC_WMARK_LOW; @@ -5278,7 +5277,6 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, /* Attempt the batch allocation */ local_lock_irqsave(&pagesets.lock, flags); pcp = this_cpu_ptr(zone->per_cpu_pageset); - pcp_list = &pcp->lists[order_to_pindex(ac.migratetype, 0)]; while (nr_populated < nr_pages) { @@ -5288,8 +5286,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, continue; } - page = __rmqueue_pcplist(zone, 0, ac.migratetype, alloc_flags, - pcp, pcp_list); + page = __rmqueue_pcplist(zone, 0, ac.migratetype, alloc_flags, pcp); if (unlikely(!page)) { /* Try and get at least one page */ if (!nr_populated)