From patchwork Wed Sep 1 09:21:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Natalenko X-Patchwork-Id: 12468779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A8FCC432BE for ; Wed, 1 Sep 2021 09:21:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0840460462 for ; Wed, 1 Sep 2021 09:21:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0840460462 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=natalenko.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B472E6B0071; Wed, 1 Sep 2021 05:21:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD19F6B0072; Wed, 1 Sep 2021 05:21:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94A058D0001; Wed, 1 Sep 2021 05:21:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 86D5D6B0071 for ; Wed, 1 Sep 2021 05:21:56 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3788E180FAA71 for ; Wed, 1 Sep 2021 09:21:56 +0000 (UTC) X-FDA: 78538462632.39.E3DB362 Received: from vulcan.natalenko.name (vulcan.natalenko.name [104.207.131.136]) by imf05.hostedemail.com (Postfix) with ESMTP id D6B45503E705 for ; Wed, 1 Sep 2021 09:21:52 +0000 (UTC) Received: from localhost (unknown [151.237.229.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vulcan.natalenko.name (Postfix) with ESMTPSA id 84F25BC74ED; Wed, 1 Sep 2021 11:21:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1630488110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=TXpryOL6VSO9ITcKmr0S/fF3J09GeRCANFPAKsu45ZY=; b=nbd9fnXVBJas6fBLM2u7Cl5iI6ipsyCds4K4K7l0KElUcUzkA0mjAoP/9EZq0SsqVZmJuo JrX/WVjfkCY4Ni1j+8iGiOafcTfJ2XM9FURaQ2dPlL9h64jrSZd+s4nHQ8OTI7P+D060BQ oM3zRQwK58ahSYXodFgpPMyT0wo2UO0= From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Vlastimil Babka , Matthew Wilcox , Greg Kroah-Hartman , Miaohe Lin , Michal Hocko , Mel Gorman , Stephen Rothwell Subject: [RFC PATCH 0/1] mm: provide one common K(x) macro Date: Wed, 1 Sep 2021 11:21:48 +0200 Message-Id: <20210901092149.994791-1-oleksandr@natalenko.name> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=natalenko.name header.s=dkim-20170712 header.b=nbd9fnXV; dmarc=pass (policy=reject) header.from=natalenko.name; spf=pass (imf05.hostedemail.com: domain of oleksandr@natalenko.name designates 104.207.131.136 as permitted sender) smtp.mailfrom=oleksandr@natalenko.name X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D6B45503E705 X-Stat-Signature: 3qzwx87de91gnmx5zt9f55zndf3n5h4n X-HE-Tag: 1630488112-57917 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: Based on discussion with Miaohe Lin [1]. There are various places where the K(x) macro is defined, sometimes under different names, sometimes it is just open-coded. In this RFC I suggest providing a common K(x) definition that replaces existing ones. For that, a new header, mm_tools.h, is created. I couldn't find a more appropriate place for K(x). Probably, an existing header like mm_inline.h would work as well. I tried placing this macro under mm.h, but then it conflicts with uapi/linux/keyboard.h. In case this approach is acceptable, replacing open-coded variants would be done in a separate patch. For now, I'm using `git grep -nE '<<\s?\(PAGE_SHIFT\s?\-\s?10\)'` to find such places. Also note, here I do not touch files under arch/ like arch/arc/include/asm/arcregs.h where PAGES_TO_KB() is defined, or arch/powerpc/platforms/pseries/cmm.c with PAGES2KB() as well as arch/s390/appldata/appldata_mem.c with P2K() as I'm not sure if it is appropriate to include another header file there. The patch is based on top of next-20210831 and is compile-tested using allyesconfig. Please let me know what you think. Thanks. [1] https://lore.kernel.org/linux-mm/9161665.bUqNH3lxUD@natalenko.name/ Oleksandr Natalenko (1): mm: provide one common K(x) macro drivers/base/node.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_base.c | 5 ++--- drivers/xen/xen-balloon.c | 11 +++++------ include/linux/mm_tools.h | 9 +++++++++ include/trace/events/writeback.h | 19 +++++++++---------- kernel/debug/kdb/kdb_main.c | 2 +- mm/backing-dev.c | 3 +-- mm/memcontrol.c | 2 +- mm/oom_kill.c | 3 +-- mm/page_alloc.c | 3 +-- 10 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 include/linux/mm_tools.h