From patchwork Mon Oct 14 10:58:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834678 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC15D1A43B for ; Mon, 14 Oct 2024 11:00:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72AE86B0095; Mon, 14 Oct 2024 07:00:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DB1B6B0096; Mon, 14 Oct 2024 07:00:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57C186B0098; Mon, 14 Oct 2024 07:00:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3BDFF6B0095 for ; Mon, 14 Oct 2024 07:00:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8BF7E160CDD for ; Mon, 14 Oct 2024 10:59:52 +0000 (UTC) X-FDA: 82671912876.04.90F950C Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 1AA26160003 for ; Mon, 14 Oct 2024 10:59:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728903553; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4YDRe8auf3W9gPGvw4mfS6WcApteYPOWnCg7H4VxM6g=; b=Xy/GJIOLMR3+ESwEA7yjyw4hl8/O8mAcUuQkMJq9RHpqOyye2XyMs00eo2X2DAZJVOFjkW 8FDKUHTihEzQXNh85XFiiuf9pZRypm1NingmKObTsnmY73CJx8w/eYKgZEVxKLlY/r2YWi R50s8E/+MZEwtWOheKM4PomsQrvOIUY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728903553; a=rsa-sha256; cv=none; b=KSR/4LC0f+Vadz6+MxJd15kMJTIZ+nKrBBk2ZnHWlS19cJoSEFGJWukoRyvufJZsfyuXHp WBQ+JIEiCJTm4VOOqPqFv+n41+eqkdHMBJRTEvYlcOxdQ80VFlBIcEya/2XY4ZDT0v9vNG CVqi+RCTGHvbT/HG9xdqS4OUsL5zNY0= 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 432CD1684; Mon, 14 Oct 2024 04:00:28 -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 D33E63F51B; Mon, 14 Oct 2024 03:59:55 -0700 (PDT) From: Ryan Roberts To: "Theodore Ts'o" , Andreas Dilger , 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-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 10/57] fs/ext4: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:17 +0100 Message-ID: <20241014105912.3207374-10-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-Rspam-User: X-Stat-Signature: mf1fu3pzchctmf5u9d4tsuyatpptnqqc X-Rspamd-Queue-Id: 1AA26160003 X-Rspamd-Server: rspam11 X-HE-Tag: 1728903594-229930 X-HE-Meta: U2FsdGVkX19/sl/0FAs5cU+0IkxrvePIOTBNZowi3Q06cOY7j6x3Hagrwlk9J/qmGIJXG2fbTINSVzeSJ8GHazh0NXyLMBBH+WvrrLqZ7D77PhZJAzacoMYN+Y1bPvz78W+hvKt1QWWcCcy2q8PFbyXE63Gyu8guxIYE9caW2M5f8eE7iwFnpVtDwZwL0duua4oLabQ9cfth+Zg+KWIGhKX4WuqGEX8VKyjN5RZfmgrl06k8auwL7AqoTGQ51aJPN6zI0cStmekZTnO/0mZOceASwevF9XFiBD4l31/GQ3WBaKRnTrb/aPD0lURZ+hYuzfnYpDge6s61yFD+MQcckpdz6joP2S1RGZfWFs6Fo6qN8ZgiPa2BbyhtWZZOcQHVDg0AHzxw3VQg8dUmXKp14O2i3P8v0Jlc8EIIx6tOFl7NVgj2rAVC6JG6UAxNzQ8bXcxt1hGRZaHCzp5XlQb+EKx5Z2B2v0EHKWkCVuczI6BnOroEhnyX8Wg31KZFrsPF6GbS+EPVeBjgX/MZ4qQZqA3tqQdLG/vkbW1Xri/TMi1JxYcaP2gvhnPrIm+JDptfOa99lT8cwQc4FOSVVF/eqvGPJXOxoIs8HI8Db0ZSXojyojAAzDDLfNTXdu4pC5XiCNyRAZ9/IY4CypFshr2sOhV1/mOekTE3xTWV/UeeCzljB3ugPtqdOPsxlWG7Pam7FJXYNh1/m7iPgP/Gg+V8n5c1jSIrH/hXnJCduF/j8UAb6u379ETdGAwT/HHEglnN3dg+spqM0SQ+oF8bhi3DEWaogZqRiiMdHtH5YCtdt4vQBpQ4+q7KFMeDYZS16szX71H5qpFwVXowgN2Bz7TfuwZGvfy5vp+Zk/ylrlB5H1yUVeM6uY1LFcik1CXOUTjB3ju8zho6mtDaNFh1JzatAv5c78eCuAVdFR+0gIS+2qNvUiuggu5DfEQXdX7h4T6Hfq20euNi4O9PT1DdMpr /46Jd2pN TM5kz1uMVjKximJAKqf+vEhXxOWwBCbUH8OLUk4btcv4kxtwaldVfcm5VSMYIDux1I9ypsWM4BfvAQILu9o65i7+13Omus7rdgidkBSTaBS7MxUbq+/GfVFP4jIjvcNZrw8y42DgxNdoJJ9ypN7o3TLctsiGcvWwleme+dJN/mrBGAc+oKIfZwMGu655Bx/PS+h+zD1zWM9UGlIz69pUW6aXoiD+rg/isC0mz 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: List-Subscribe: List-Unsubscribe: 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 CPP PAGE_SIZE conditionals to C if/else. For compile-time page size, the compiler will strip the dead part, and for boot-time page size, the condition will be evaluated at run time. 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/ fs/ext4/ext4.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd152261ed..1a6dbd925024a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2415,31 +2415,31 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize) { unsigned len = le16_to_cpu(dlen); -#if (PAGE_SIZE >= 65536) - if (len == EXT4_MAX_REC_LEN || len == 0) - return blocksize; - return (len & 65532) | ((len & 3) << 16); -#else - return len; -#endif + if (PAGE_SIZE >= 65536) { + if (len == EXT4_MAX_REC_LEN || len == 0) + return blocksize; + return (len & 65532) | ((len & 3) << 16); + } else { + return len; + } } static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) { BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3)); -#if (PAGE_SIZE >= 65536) - if (len < 65536) + if (PAGE_SIZE >= 65536) { + if (len < 65536) + return cpu_to_le16(len); + if (len == blocksize) { + if (blocksize == 65536) + return cpu_to_le16(EXT4_MAX_REC_LEN); + else + return cpu_to_le16(0); + } + return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); + } else { return cpu_to_le16(len); - if (len == blocksize) { - if (blocksize == 65536) - return cpu_to_le16(EXT4_MAX_REC_LEN); - else - return cpu_to_le16(0); } - return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); -#else - return cpu_to_le16(len); -#endif } /*