From patchwork Wed Sep 25 15:55:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leesoo Ahn X-Patchwork-Id: 13812298 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 746CECCF9E4 for ; Wed, 25 Sep 2024 15:56:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D69F16B00B0; Wed, 25 Sep 2024 11:56:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D189F6B00B2; Wed, 25 Sep 2024 11:56:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C07DD6B00B3; Wed, 25 Sep 2024 11:56:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A19A86B00B0 for ; Wed, 25 Sep 2024 11:56:31 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 49B5BA0D49 for ; Wed, 25 Sep 2024 15:56:31 +0000 (UTC) X-FDA: 82603712982.10.95B7707 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf09.hostedemail.com (Postfix) with ESMTP id 796F2140010 for ; Wed, 25 Sep 2024 15:56:29 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727279669; 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:references; bh=/EGKCLuEpsZX8eShN6EA6IJ5o9oCBmRtPZ33EEovFzc=; b=qYTIMf/sCqQXUZ7bfSyOPMD+EGw0n6ggjx+N1FLpdtJ7o80JQyFEhgoavBS35lGXWb5CaF StnGGcR5ctAonLgvoJFZahH37gECuXHoVBCnFzP/g2YZqafGl6Z/f2FSKkz/aOAP/6JQFh pWHgo2skdzafyGC3GhnQxulw6l9mqKM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727279669; a=rsa-sha256; cv=none; b=m4HT3hTg3zlOnmO1PjKwyNXoyJpcU013j0EhgH9RAdI2dq98/ZCnxqTGa4aVYglCHxE3BY tvsaHmSuXSglT+sRZV/NLq4F8P0ESz7EHrmTWbhWmUJP65cQPAKimbYF0J5+Gj/EGP4IAY yCrukrMOPYYHxPn1fd8k5WS+imVtAEg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com; dmarc=none Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-71798661a52so70609b3a.0 for ; Wed, 25 Sep 2024 08:56:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727279788; x=1727884588; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/EGKCLuEpsZX8eShN6EA6IJ5o9oCBmRtPZ33EEovFzc=; b=dJJhnE4C6cjEyaOuL4CFeFqCRxR2dIOzTYYC5eYuBnaqpf8XAh7WBK75JXYpJG5ygk 1ZYgoGeVQr1Q/vE0MUbY1kFIzYPBXgyTg+POJKuWUXHeA9qWKvswuKSlJi94p3ayZcuV c81nVlSrZdj9oyaEHm8T0wX71RUnl0gW3RVmgqgUXlI6f8Mc6UJ9ayWxxgq/Jn7aKgZq 8oSGtsXXHncYzLx4PPGJz7gP5QQzeqLBA14J+FA17AAikZ+xoqSfb1lZuCus5oXBcDRO 3LhGaTLeC+CcLeTPa1agq0BIL3XnZc2tMPBUMSdZI+jPPytFjR4uDxJ3ELEfvzkGU7Ql tqNA== X-Forwarded-Encrypted: i=1; AJvYcCU8/jXQQjZDyFJJxnANG5PqSV6aHzy/7HhQgoHqVw4PSPHAReZArW9dAxF0hf0aQZ7kJUQNeSprrA==@kvack.org X-Gm-Message-State: AOJu0YzwJGYW2yJbLNJ5oDLDcUuzxyB8ozQtKUtbjCFDr5zGEgA9Ds3R /PUWVBiL8AhFxU0KAjB9dQ+S+Pf61yJtiA60ebeWTqMilpeZLCioPugYgQ== X-Google-Smtp-Source: AGHT+IFfjaADO2ScvbyWwiOLTtmupiLDz5RwaOB779NvMl7Z1bVFoWk8AH6+X/sXpaD7Q1r9lnG0BA== X-Received: by 2002:a05:6a00:3d41:b0:717:92d8:ca5c with SMTP id d2e1a72fcca58-71b19250df2mr168153b3a.3.1727279788055; Wed, 25 Sep 2024 08:56:28 -0700 (PDT) Received: from localhost.localdomain ([1.213.237.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71afc834fdbsm2932222b3a.20.2024.09.25.08.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 08:56:27 -0700 (PDT) From: Leesoo Ahn To: lsahn@wewakecorp.com Cc: Leesoo Ahn , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mmzone: remove redundant exception handler on pfn_valid() Date: Thu, 26 Sep 2024 00:55:28 +0900 Message-ID: <20240925155540.4087150-1-lsahn@ooseel.net> X-Mailer: git-send-email 2.46.1 MIME-Version: 1.0 X-Stat-Signature: fjijhxtwjh41hbr45ih67bobzt4bn775 X-Rspamd-Queue-Id: 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GJ2OB6qz5nvE1vHOP4Uo/JX8vE7/JBneTaEJd0aya06r80fbHlS21LO9fpljzUHn66QAVhQMSS4JWEk3QTxy1wXyQ0H1vkrCQVG7xS9/GnAoPBIJPIcUU9dBLxk/z95TOb2X/xCh4sg6k77S/lbtqak708OHH970Naz+i+06bOwZD8Z79YKGqWYW+VOfqzcenzGbW+V6wgz3I/lxX0tntvTOqskfWhx7BE/x1yjUkrUFgV29FT4wmnW1E5L/eTK4MJAmkiwyw7Oml5FreKE51+VE3/v2A+tiPpvHjBI4vqkr3NZ6sqKvhi1kv4Ze5nBYKa4U54DwoybeuPuFIznq29X72W8f9GuQyy8Ucp0lHLO6g5CqYPpBxlLxAGNaTuvcsf+uq 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: 1). It can ensure the upper PAGE_SHIFT'ed bits of PHYS_PFN(..) are clear by the C11 standard: 6.5.7 Bitwise shift operator ... The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 / 2^E2. @pfn parameter of pfn_valid(..) is unsigned long and PHYS_PFN(..) makes the upper bits clear(zero) always with it. Otherwise, the result of E1 / 2^E2 doesn't make sense in the document. 2). x86 instructions The following x86 instructions are the part of the redundant exception handler: ... movabs $0xfffffffffffff,%rax and %rdi,%rax cmp %rax,%rdi je 22 xor %eax,%eax jmp __x86_return_thunk 22: push %rbp ... %rdi would be the @pfn parameter of pfn_valid(..) and -1 assigned to %rax. 'je' always takes place by %rdi AND and CMP ops with %rax. Therefore, the exception handler is unnecessary. Signed-off-by: Leesoo Ahn --- include/linux/mmzone.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 17506e4a2835..164ae80977d6 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -2028,15 +2028,6 @@ static inline int pfn_valid(unsigned long pfn) struct mem_section *ms; int ret; - /* - * Ensure the upper PAGE_SHIFT bits are clear in the - * pfn. Else it might lead to false positives when - * some of the upper bits are set, but the lower bits - * match a valid pfn. - */ - if (PHYS_PFN(PFN_PHYS(pfn)) != pfn) - return 0; - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) return 0; ms = __pfn_to_section(pfn);