From patchwork Fri Jul 26 07:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leesoo Ahn X-Patchwork-Id: 13742413 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 B9FA3C3DA49 for ; Fri, 26 Jul 2024 07:11:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E8C26B0096; Fri, 26 Jul 2024 03:11:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 298BC6B0099; Fri, 26 Jul 2024 03:11:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 160E26B009B; Fri, 26 Jul 2024 03:11:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E1F716B0096 for ; Fri, 26 Jul 2024 03:11:08 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8DFF6A61AB for ; Fri, 26 Jul 2024 07:11:08 +0000 (UTC) X-FDA: 82381032216.26.D73932F Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf16.hostedemail.com (Postfix) with ESMTP id 90E1B180021 for ; Fri, 26 Jul 2024 07:11:05 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kOHiR4xR; dmarc=none; spf=pass (imf16.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721977864; a=rsa-sha256; cv=none; b=RzzOmb9ccBGOqTUDypBKgpbdN5wImtTDAkDy3VimrMA+D5YMiEkHlZrG5y1WBzR+0ZsSYU Zd7RbFYNoEmm1hJyTtW65BfUBbK0t8FXCziON/9Mg0VB8qFOE/pg/AAEObA6AriUaeARxL CKStupt7iu2g4VndVyUek+qtlQvvDUw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kOHiR4xR; dmarc=none; spf=pass (imf16.hostedemail.com: domain of yisooan.dev@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=yisooan.dev@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721977864; h=from:from:sender: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:dkim-signature; bh=IRwB2VYbJi/ARjTBQHl2ucJrLiHTbO9zck6Jgublm1s=; b=KziPkv/vuHeBfSFF8tGDvd9kP6R6pqqT/VMaG3O3ZJ5mgwsQ/mmodQje7TNM1ytDTR6WpS joXy6zR6l7v8rLNhnVcQ8jFaJWKDPCFVHpwy/Zj1+7EIdzg9tNoM0kodg+vbzkxT+M3NYF 4gWzBJmG4A4ZYgWWp2SZaHHEH7umlhI= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-70d1c8d7d95so443729b3a.2 for ; Fri, 26 Jul 2024 00:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721977864; x=1722582664; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=IRwB2VYbJi/ARjTBQHl2ucJrLiHTbO9zck6Jgublm1s=; b=kOHiR4xRpz5YCU3CdqL4j/bBhvw+1fnUFhe3M4WrMK3JQDJIMWqhbYDWw8l2aKA8Hq 1MxkLIIyA97QTR4IE/pTo9dpjPZdyrHEN7LiA/jRhu3idy4PKWdddzPnyYZ3UeZrusBl 7zVwTjdMeZEkZAxXfbTQwti93pKtrfAOWwqZxhRyecMb++5QxbOIKsQqsyOUkbNjXpqw TRaKx//WJUPPxDYRGOs0Dt2zH1VVeCQQ+usqwLTHj5VwHC7xJ2E6xXD3joXKt3htO55x ylhl0c8ALvvXAWsECnrID6TzXb1VBV35c5r4zoduD0T960keagtq39E8jldLHviOJ/IA EBvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721977864; x=1722582664; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IRwB2VYbJi/ARjTBQHl2ucJrLiHTbO9zck6Jgublm1s=; b=tFrq2dzL+zHwxTLTjru7zIRQX+fK9NIEaOeFPWxePzJN7DZoW7eiI77QfxYzDAtHX4 jVteytSotw7AFqL3nfhy668wyQG/NvMRfQB9PBqp8nuBI+Jath4JPfuu3NtSS8H74Vq1 2WOFjXWs77E3A1LEsvCloZNPBUPlX2SFuzJ6exy1Hz0UZT4kHqoDxkG8Wzq04/PIr+5O BVUVvgs1eO0OJ/Iq3gp+BWcYfmVmRfHXU0LT84X57UGuq5OliHhKly9fsSkugBxzWxsK 2EKJcGf74D5odMl198sMH6rTud+v5C5DuekcT2dqQ5tBvCYAgeN8PXZykTw87BYnKrwV gucg== X-Forwarded-Encrypted: i=1; AJvYcCWpu19YMBOENM6SHCdmAzLclN0LEtwlQxweNQUilcbpu6IqbmDXgmfGzv5VYQ5jdFxAF+QYAZYliw==@kvack.org X-Gm-Message-State: AOJu0YxE2XqWlTyBNEx0RaW4fXmyKfUy5Dg34jkp3Sb8ffb6ImD0MDzf 3IFTfOtef8mbL1UDVevG9yhgBRpVsNGBcewOZEJuOezT7LfL4Vg78lFfkw== X-Google-Smtp-Source: AGHT+IFxKTI0hi7yZlMUCGv6/+Isn9gBEnoyMqF/N6W+HG2hH76+Itzus3wNEOsL8ORitnN3iDdmZw== X-Received: by 2002:a05:6a21:3983:b0:1c2:8e96:f767 with SMTP id adf61e73a8af0-1c472aabf13mr6944335637.31.1721977864003; Fri, 26 Jul 2024 00:11:04 -0700 (PDT) Received: from SYSOS.. ([115.178.65.130]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cf28c5668esm2644789a91.1.2024.07.26.00.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 00:11:03 -0700 (PDT) From: Leesoo Ahn X-Google-Original-From: Leesoo Ahn To: lsahn@ooseel.net Cc: Leesoo Ahn , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm/sparse: return right away if sparsemap_buf is null Date: Fri, 26 Jul 2024 16:10:23 +0900 Message-Id: <20240726071023.4078055-1-lsahn@wewakecorp.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 90E1B180021 X-Rspamd-Server: rspam01 X-Stat-Signature: n6qrbrtajhtnsraxnw3us3i7ez9e7eoa X-HE-Tag: 1721977865-98093 X-HE-Meta: U2FsdGVkX1+3eBuvhTAkcamfg2Vt+MEwCMzn0KgdwT1twLrlKP1UCl3p0Sy2tYhnt58fxyPvYcINM30WSIZlAIfB4O5tG6Rp0MztEdC/eUbp5GQ9B9OjhgSTOjGVcg5gMu8br8++bdcsIhUhdtiUTez2ad1aRPThDjhbN+oMW35kZ8kdbFb6z1LkdhIFUhti0aKx368VDjDGYfzc5Y21kw6AgravUsidHjEstDY5xT8clzVdAH3p6V6BpHs1GqYBDiboQvOYZERmtilUKec7o2cvyrkyEzPgputdzRg2zEnLHu5QPxpfBPBk66kcYp6VNx/ZvcFUkD5urJ34BQA8r3cfICa/xF4SrDDlNPYP6RYcuYtRoetlIpXLI8I4mjjamoOPUG3+RqHr3w+n3Dw8m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.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: sparse_buffer_fini(..) takes the following actions even though the value of sparsemap_buf is NULL, 1. calculate size of sparsemap buffer (which is meaningless). 2. set sparsemap_buf variable to NULL (although it is already NULL). These steps are unnecessary if the variable, sparsemap_buf is NULL. Refactor the function to return right away if the variable is NULL. Hence, it doesn't need to take further actions. Signed-off-by: Leesoo Ahn --- mm/sparse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index e4b830091d13..091e4bc2f72c 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -469,9 +469,13 @@ static void __init sparse_buffer_init(unsigned long size, int nid) static void __init sparse_buffer_fini(void) { - unsigned long size = sparsemap_buf_end - sparsemap_buf; + unsigned long size; - if (sparsemap_buf && size > 0) + if (!sparsemap_buf) + return; + + size = sparsemap_buf_end - sparsemap_buf; + if (size > 0) sparse_buffer_free(size); sparsemap_buf = NULL; }