Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3458859ioo; Wed, 25 May 2022 00:38:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRv1OglLkFzTuOAA2gGxL/qUl05igG2MzKudgxoGkPm3X5Mw8J2KTWPEEKnwVe/MblIWP4 X-Received: by 2002:a17:907:6d81:b0:6fe:b89d:80ba with SMTP id sb1-20020a1709076d8100b006feb89d80bamr18960317ejc.699.1653464338170; Wed, 25 May 2022 00:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653464338; cv=none; d=google.com; s=arc-20160816; b=IeqTGCHh5yPvjp2EnZ/mFOwxJ4WSdrEpWE/gsOMOaHU42cfe/dkkCPte1FRvW674vO VAFvA/t/Z+++AjzEegOnV7pAwCjr7zd2xiVSKxOdQoFicg5LQbt+YOiyarttXp3DZJ57 i1T9Of7Ev6hsKOJ2UvgSgYAWpnIkimPE7SMhtfGpc/UtS/637DnKST/YjtBCRkh+bKKi iImPYeUlELGi+RMJSEVddXceJ/Qg1Q3VEbcoO/e4yK194hFbw+jYqOwX6B9B0H1/uPXR tSRrY6pq30lBviRXnXGwuXpqd0cl0lLj4o0WRtFN/iyQdkIMyttFwfm2NshYGei8tEMZ e7AQ== 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=0Ns37PS0Z/9dAZc3+5Pg5SnjIrok42yaWDTbYdkq5BE=; b=aOWQO7kq2Se4Cap1AQYUQr1j+Am2pA6j41TEa1g1La3TZhbbQkLaRsromupXYCaxbL UFEqZmhbN1qMY4J8oddfgUgFBpDRqQ6NBrazc0h0mmtbdIeF3mybbs/DUaAhErnEjCOe t7PEmjgrgYerwvWa/S152mXwlSU5c9ID8ijW0sEW1ucVJS9AaUwf4Wg26GXB4ieHacmT wQF0Lp1uE4vdeQwSoTlUmK7jFjMDyfM9qgAI6gJIfJ65GYBG4DEaPDnzLDM/XCJHH2cT kTwqXN5iNGiHfaF7N8RSopCXyhutiSzkTlV6+0OwEjXl307+VEBJ4yxySgio57W7uNys ZVfA== 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 dm12-20020a170907948c00b006fe7927ad4esi21319935ejc.578.2022.05.25.00.38.27; Wed, 25 May 2022 00:38:58 -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 S237811AbiEYDjg (ORCPT + 99 others); Tue, 24 May 2022 23:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235282AbiEYDje (ORCPT ); Tue, 24 May 2022 23:39:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5FDB068FA8 for ; Tue, 24 May 2022 20:39:31 -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 BB9851FB; Tue, 24 May 2022 20:39:30 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.37.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C7BDE3F70D; Tue, 24 May 2022 20:39:27 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , David Hildenbrand , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH] mm/memory_hotplug: Drop 'reason' argument from check_pfn_span() Date: Wed, 25 May 2022 09:09:09 +0530 Message-Id: <20220525033910.3781764-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. Currentlyy there are just two callers for check_pfn_span() i.e __add_pages() and __remove_pages(). Let's clean this up. Cc: David Hildenbrand Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- mm/memory_hotplug.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 416b38ca8def..9b3d7295ef93 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,11 @@ 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) + err = check_pfn_span(pfn, nr_pages); + if (err) { + WARN(1, "Misaligned %s start: %#lx end: #%lx\n", __func__, pfn, pfn + nr_pages - 1); return err; + } for (; pfn < end_pfn; pfn += cur_nr_pages) { /* Select all remaining pages up to the next section boundary */ @@ -518,8 +515,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