Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1688420ioo; Fri, 27 May 2022 14:27:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEU13rMRLuMX2wq6XkFS0T7LmCZ37979tspFBvdploPT5kSGp04JfJI/Va6gYVAqmWWTPS X-Received: by 2002:a63:8b42:0:b0:3fa:e052:cf4e with SMTP id j63-20020a638b42000000b003fae052cf4emr12360915pge.557.1653686866508; Fri, 27 May 2022 14:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653686866; cv=none; d=google.com; s=arc-20160816; b=SK3ps6AlFcik6bnSS1UK5BnovSTwgyUoiHLrz+CK6ovi6kWxcFmdzQU1FAefm5jRYl V0O89cm0CbKVGf+k0nHxFoVy+Am+E7qILn1n7NpVBKvcei/6Sg78CiUf1Db0hEypBF+a yiD3MOGiuXVDcH39EJ76sc4aLjrrBBRRyB2qRV5e6j8p7aW4RZAXoPbRuiSsXWdd1I2N UlELQzbeWvdpQOXzY740j4jX5icg2SddidOb6l4FaSbI8r5+6DhgspM+SQhyIOsE116Z Buw706WEeSPctji+eImc0XJ/95MWVxksboIU9hU7Ba5IE6NOBMuLSH2Pgq+Nm+jyOoTO sAEw== 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 :message-id:date:subject:cc:to:from; bh=KlHaDtp8kbyYatZre4oc2dkWbl4WaA6q4rCOTfE2n88=; b=Jm+EK4b4ck276mRxYHWNyGykqg2j7BaTA068NhjIzNycpHbmuG/uqDEIXtf8CkQqZo X/kIB367Nio60gXbL0dIemGJWfCVwT0SpqCV2sYzwTDopafGMv4IKB4JyC6lqhBXukhu N56cNO++EchnURyKS3rEaZobeku3PXAHccs3FzsUy43cVlLyXvHEPaTcUMNBwwY1p8jX rIq8CAKLp/DKFy64M903xtgZDFkCHLgs0GtXmOiI4ls4bSC1KT+nnN4Sx8z4eG74Trow 9ZdFS7EL2Awosg964QiipdgLZk9SB/nf09Yh9//ZGZkhiS+nWJzHWr0dOtIKnS8bgKuX vc5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a17090301c100b001636f1ee468si8152237plh.126.2022.05.27.14.27.32; Fri, 27 May 2022 14:27:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345920AbiEZCNO (ORCPT + 99 others); Wed, 25 May 2022 22:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbiEZCNK (ORCPT ); Wed, 25 May 2022 22:13:10 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 326F78BD0A for ; Wed, 25 May 2022 19:13:08 -0700 (PDT) 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 6E3421474; Wed, 25 May 2022 19:13:08 -0700 (PDT) Received: from a077893.blr.arm.com (unknown [10.162.43.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 124103F70D; Wed, 25 May 2022 19:13:05 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Oscar Salvador , David Hildenbrand , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH V2] mm/memory_hotplug: Drop 'reason' argument from check_pfn_span() Date: Thu, 26 May 2022 07:42:58 +0530 Message-Id: <20220526021258.4030749-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In check_pfn_span(), a 'reason' string is being used to recreate the caller function name, while printing the warning message. It is really unnecessary as the warning message could just be printed inside the caller depending on the return code. Currently there are just two callers for check_pfn_span() i.e __add_pages() and __remove_pages(). Let's clean this up. Cc: Oscar Salvador Cc: David Hildenbrand Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- Changes in V2: - Fixed typo in commit message - Dropped using 'ret' to capture check_pfn_span() return value in __add_pages() Changes in V1: https://lore.kernel.org/all/20220525033910.3781764-1-anshuman.khandual@arm.com/ mm/memory_hotplug.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 416b38ca8def..3b24386e9276 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -220,8 +220,7 @@ static void release_memory_resource(struct resource *res) kfree(res); } -static int check_pfn_span(unsigned long pfn, unsigned long nr_pages, - const char *reason) +static int check_pfn_span(unsigned long pfn, unsigned long nr_pages) { /* * Disallow all operations smaller than a sub-section and only @@ -238,12 +237,8 @@ static int check_pfn_span(unsigned long pfn, unsigned long nr_pages, min_align = PAGES_PER_SUBSECTION; else min_align = PAGES_PER_SECTION; - if (!IS_ALIGNED(pfn, min_align) - || !IS_ALIGNED(nr_pages, min_align)) { - WARN(1, "Misaligned __%s_pages start: %#lx end: #%lx\n", - reason, pfn, pfn + nr_pages - 1); + if (!IS_ALIGNED(pfn, min_align) || !IS_ALIGNED(nr_pages, min_align)) return -EINVAL; - } return 0; } @@ -320,9 +315,10 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, altmap->alloc = 0; } - err = check_pfn_span(pfn, nr_pages, "add"); - if (err) - return err; + if (check_pfn_span(pfn, nr_pages)) { + WARN(1, "Misaligned %s start: %#lx end: #%lx\n", __func__, pfn, pfn + nr_pages - 1); + return -EINVAL; + } for (; pfn < end_pfn; pfn += cur_nr_pages) { /* Select all remaining pages up to the next section boundary */ @@ -518,8 +514,10 @@ void __remove_pages(unsigned long pfn, unsigned long nr_pages, map_offset = vmem_altmap_offset(altmap); - if (check_pfn_span(pfn, nr_pages, "remove")) + if (check_pfn_span(pfn, nr_pages)) { + WARN(1, "Misaligned %s start: %#lx end: #%lx\n", __func__, pfn, pfn + nr_pages - 1); return; + } for (; pfn < end_pfn; pfn += cur_nr_pages) { cond_resched(); -- 2.20.1