From patchwork Mon Oct 14 10:58:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834862 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33400D1624F for ; Mon, 14 Oct 2024 12:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xJWf5Towi95SWggcq2L3OEdCfoka1zUWhvozEl9HTkI=; b=08Jp/dqnQI2PNt4/LkkM4UOuaC MowcFfREe79Zk+z8SNkOB1QeV2b/LqdFlDaXVHsS1qHSEJRyiAYZKGXOvnP5cUFzEoVrQ066drFeo hstGZ6xxNwzE3e0nwciug4AB9ME+Cn2Nsy3qumuUp84WZZLqYjTCAE0w65MOJ/iIZfEcChLLYY8em YRD/eO2h4PQxWJa5XTC722I8ANNGWrKAydFl5sGke85x1E0SSclTLt76vrTaZo1l0oVWK4bfIiU9l A5wlwvKCq3cms4WUTnpbnc8wJ3ceR6W9l5yZE6dG/craBz3vrLQDsPPZthaOo8jxI36EjpZOQvHJ/ sgmSbrpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0JrA-000000051kl-2OKk; Mon, 14 Oct 2024 12:07:24 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Ioz-00000004o8q-3406 for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 11:01:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D88E716F8; Mon, 14 Oct 2024 04:01:34 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B95D73F51B; Mon, 14 Oct 2024 04:01:02 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 31/57] edac: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:38 +0100 Message-ID: <20241014105912.3207374-31-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_040106_025076_4390EDB3 X-CRM114-Status: GOOD ( 11.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To prepare for supporting boot-time page size selection, refactor code to remove assumptions about PAGE_SIZE being compile-time constant. Code intended to be equivalent when compile-time page size is active. Convert PAGES_TO_MiB() and MiB_TO_PAGES() to use the ternary operator so that they continue to work with boot-time page size; Boot-time page size can't be used with CPP because it's value is not known at compile time. For compile-time page size builds, the compiler will dead code strip for the same result. Signed-off-by: Ryan Roberts --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ drivers/edac/edac_mc.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h index 881b00eadf7a5..22132ee86e953 100644 --- a/drivers/edac/edac_mc.h +++ b/drivers/edac/edac_mc.h @@ -37,13 +37,12 @@ #include #include -#if PAGE_SHIFT < 20 -#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT)) -#define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT)) -#else /* PAGE_SHIFT > 20 */ -#define PAGES_TO_MiB(pages) ((pages) << (PAGE_SHIFT - 20)) -#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20)) -#endif +#define PAGES_TO_MiB(pages) (PAGE_SHIFT < 20 ? \ + ((pages) >> (20 - PAGE_SHIFT)) :\ + ((pages) << (PAGE_SHIFT - 20))) +#define MiB_TO_PAGES(mb) (PAGE_SHIFT < 20 ? \ + ((mb) << (20 - PAGE_SHIFT)) : \ + ((mb) >> (PAGE_SHIFT - 20))) #define edac_printk(level, prefix, fmt, arg...) \ printk(level "EDAC " prefix ": " fmt, ##arg)