Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4530706pxb; Tue, 31 Aug 2021 07:21:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFiMqHvkBTcP1bmHuX1pXYH8ZZ0TtzgS8V43XD+JRFvFBcVc1HbuG+PZCGYx/5kuDm40xA X-Received: by 2002:a05:6e02:dcc:: with SMTP id l12mr20547765ilj.20.1630419683252; Tue, 31 Aug 2021 07:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630419683; cv=none; d=google.com; s=arc-20160816; b=zMt1vUEmdNRZDSEpVDOoxeIbvJgP9Tu3G5GbyUVU4i+rhSgwghKqDB0/Jx3sIi9tOt ENdMTQRD+KTC1CKPfBk1Y4/P2gj6YPx6M48UShpuAfncFpaJ+ovXKmUiMLfttUNnistn 2Z8C1tAYSisgpeV3k0Btjpx1WKZOI52VitUgT+C3vrlhlIWjvshY2EzvFlGcs0G8sssG hHbtFlm6V+6QcTkFfPtSLYO1iFjmmAQ1BTx8JE7rT/bGRY/zISBeXawJLB8hYnxwoODV KmVnDFG6X/865ANsRiaOPrSQk+x3AbmpNhGd+nNG8Wqjjv/EPphAI7NnTiRwPYfiXTp+ FMTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9VeBKeJ05t6np4FlW97smb4L774a58zRoIObnDWLK0Y=; b=iaq4b6KFrRQWjNH2c37zXiYq7PWNoNwqE8zB/MjDQ1skNRw+prRTPqFRHJJvkCvSNs ysLnEIi/3ZyTYsCPg/5hEFuvuDjt54laFUCg3hgBsK64JTXewnLKf08RdZm2g1Wl0wBT M10niQu997OApOvFo33cbuqM/frfsle++elJD/57frJllgHq1DUk6QmnELqxBKshhiqW 7SpbAHWRauXAYl+l+pxHAlNBLsNa0t0tkob/SJOJuVvrx+InIKV3V4xq+FQpv9SUywNE PH9ngM9Hd+iopoLA52O5A4njO7805SlnXdFPASiIxFGS84633W7NM0mGAk+NGAYqGfci 9SnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=VwWYzK3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si15812690iom.0.2021.08.31.07.21.10; Tue, 31 Aug 2021 07:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=VwWYzK3+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbhHaOU0 (ORCPT + 99 others); Tue, 31 Aug 2021 10:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbhHaOUZ (ORCPT ); Tue, 31 Aug 2021 10:20:25 -0400 Received: from vulcan.natalenko.name (vulcan.natalenko.name [IPv6:2001:19f0:6c00:8846:5400:ff:fe0c:dfa0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0DFFC061575 for ; Tue, 31 Aug 2021 07:19:27 -0700 (PDT) Received: from spock.localnet (unknown [151.237.229.131]) (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 vulcan.natalenko.name (Postfix) with ESMTPSA id D0D53BC580A; Tue, 31 Aug 2021 16:19:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1630419565; 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=9VeBKeJ05t6np4FlW97smb4L774a58zRoIObnDWLK0Y=; b=VwWYzK3+aXVtW6Bt32XuwLs8bTCHqhPth47Kxs4FOv7Z1EdFUh4dKgU/cJrJuRB7zS2L/S ++2x8A9IPi0BGswv6MZEkGaiJM3VH97hNmKrAYFyqTE0zVohr63h9r2l/Yf/0uLneWj2tG uoqVf7DlnYVyHh/izPjBhI+VboPAD7Q= From: Oleksandr Natalenko To: Miaohe Lin Cc: vbabka@suse.cz, sfr@canb.auug.org.au, peterz@infradead.org, mgorman@techsingularity.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH 2/6] mm/page_alloc.c: simplify the code by using macro K() Date: Tue, 31 Aug 2021 16:19:23 +0200 Message-ID: <9426505.MgecbftzqH@natalenko.name> In-Reply-To: <52bbb8f2-db63-8c56-ea49-d982c13ba541@huawei.com> References: <20210830141051.64090-1-linmiaohe@huawei.com> <9161665.bUqNH3lxUD@natalenko.name> <52bbb8f2-db63-8c56-ea49-d982c13ba541@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello. On =C3=BAter=C3=BD 31. srpna 2021 13:08:42 CEST Miaohe Lin wrote: > On 2021/8/31 16:54, Oleksandr Natalenko wrote: > > Hello. > >=20 > > On pond=C4=9Bl=C3=AD 30. srpna 2021 16:10:47 CEST Miaohe Lin wrote: > >> Use helper macro K() to convert the pages to the corresponding size. > >> Minor readability improvement. > >>=20 > >> Signed-off-by: Miaohe Lin > >> --- > >>=20 > >> mm/page_alloc.c | 12 +++++------- > >> 1 file changed, 5 insertions(+), 7 deletions(-) > >>=20 > >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c > >> index dbb3338d9287..d3983244f56f 100644 > >> --- a/mm/page_alloc.c > >> +++ b/mm/page_alloc.c > >> @@ -8134,8 +8134,7 @@ unsigned long free_reserved_area(void *start, vo= id > >> *end, int poison, const char } > >>=20 > >> if (pages && s) > >>=20 > >> - pr_info("Freeing %s memory: %ldK\n", > >> - s, pages << (PAGE_SHIFT - 10)); > >> + pr_info("Freeing %s memory: %ldK\n", s, K(pages)); > >>=20 > >> return pages; > >> =20 > >> } > >>=20 > >> @@ -8180,14 +8179,13 @@ void __init mem_init_print_info(void) > >>=20 > >> ", %luK highmem" > >> =20 > >> #endif > >> =20 > >> ")\n", > >>=20 > >> - nr_free_pages() << (PAGE_SHIFT - 10), > >> - physpages << (PAGE_SHIFT - 10), > >> + K(nr_free_pages()), K(physpages), > >>=20 > >> codesize >> 10, datasize >> 10, rosize >> 10, > >> (init_data_size + init_code_size) >> 10, bss_size >> 10, > >>=20 > >> - (physpages - totalram_pages() - totalcma_pages) << (PAGE_SHIFT > >=20 > > - 10), > >=20 > >> - totalcma_pages << (PAGE_SHIFT - 10) > >> + K(physpages - totalram_pages() - totalcma_pages), > >> + K(totalcma_pages) > >>=20 > >> #ifdef CONFIG_HIGHMEM > >>=20 > >> - , totalhigh_pages() << (PAGE_SHIFT - 10) > >> + , K(totalhigh_pages()) > >>=20 > >> #endif > >> =20 > >> ); > >> =20 > >> } > >=20 > > (my concern is not quite within the scope of this submission, but I'll = ask > > anyway) > >=20 > > Given we have this: > >=20 > > ``` > > git grep '#define K(x)' v5.14 > > v5.14:drivers/base/node.c:#define K(x) ((x) << (PAGE_SHIFT - 10)) > > v5.14:drivers/net/hamradio/scc.c:#define K(x) kiss->x > > v5.14:kernel/debug/kdb/kdb_main.c:#define K(x) ((x) << (PAGE_SHIFT - 10= )) > > v5.14:mm/backing-dev.c:#define K(x) ((x) << (PAGE_SHIFT - 10)) > > v5.14:mm/memcontrol.c:#define K(x) ((x) << (PAGE_SHIFT-10)) > > v5.14:mm/oom_kill.c:#define K(x) ((x) << (PAGE_SHIFT-10)) > > v5.14:mm/page_alloc.c:#define K(x) ((x) << (PAGE_SHIFT-10)) > > ``` > >=20 > > Shouldn't this macro go to some header file instead to get rid of define > > repetitions? >=20 > Many thanks for figuring this out. I think we should get rid of these > repetitions too. But I'am not sure where this definition should be. Any > suggestion? Thanks. I'm not sure what place suits best. At first I thought maybe linux/mm.h or= =20 linux/mm_inline.h, but since PAGE_SHIFT is declared in asm-generic/page.h,= =20 probably K(x) can also go there as well? =2D-=20 Oleksandr Natalenko (post-factum)