From patchwork Tue Jun 4 06:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Granados via B4 Relay X-Patchwork-Id: 13684738 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 0D5AEC25B7E for ; Tue, 4 Jun 2024 06:30:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C469B6B0099; Tue, 4 Jun 2024 02:30:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCC036B009A; Tue, 4 Jun 2024 02:30:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A03546B009B; Tue, 4 Jun 2024 02:30:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 820DC6B0099 for ; Tue, 4 Jun 2024 02:30:08 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 01BFE4095F for ; Tue, 4 Jun 2024 06:30:07 +0000 (UTC) X-FDA: 82192231296.06.E6588E2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 4562610000A for ; Tue, 4 Jun 2024 06:30:04 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cypzoF8H; spf=pass (imf14.hostedemail.com: domain of devnull+j.granados.samsung.com@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=devnull+j.granados.samsung.com@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717482606; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OCcw4Iwb7QwzY/s7rwXs+uaUycHgTYIKpDyBqKJN9KA=; b=7ZdUjOa7PmNDu4nBp7EvjXlqrSDsQGDs35P0Vgrnd93VftoHLBF4fXlVw1zzeBgH+dtBrC 7iStCXK3vTypMiOpZVa5cgNKceUWWRQM9qbxA9zz7HvhheqoEmhxiUSZhA0MdrxgnmzIAs V2k5VHgIcF0j56SII/qp+PdSqWHtD/E= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cypzoF8H; spf=pass (imf14.hostedemail.com: domain of devnull+j.granados.samsung.com@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=devnull+j.granados.samsung.com@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717482606; a=rsa-sha256; cv=none; b=uiDHYNBApZuCSWsSrm52qkIu1pUxLoO81MfgDU0nFinCd2TnOUvFpL51sZI3ZEGbPqqVdc koexLsq4qTHelj/dMXh5XyX4ASFpZhHX51poB3Q1FQPzLqSj6PS9V7N5EHABOVXmWcVheq tBeWb8f9MOT1aVwCVLK0ly3sfaj/OnM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9645DCE1025; Tue, 4 Jun 2024 06:30:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id C6F46C4AF0E; Tue, 4 Jun 2024 06:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717482599; bh=+9m/xQlKsI8pqumJbCIgfUOr4dYZwdwxkZ7BbsD0p9w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cypzoF8HBNiKPC2nUW6/CDayI/9sb7tk1EtuIsF5LNkC/Vvb+lntmVYJEU2yPN3dA Ywxo0gc6flAZv29VpNp3LTsFajnFwGDogaqn6kUhNBrkFgUN3kNw2mvICiomWHaW1o N+5Gyr8ievMcOl/NAHnguvAJGOeRS/NOsViAWyNA+2fmH116RFJjF2A3licAft8U4L WcJb4OJewURJ4scZFVIoFS4fPM5kEwyLzJJLmbsLKAa3s1isHrTUfrwnxbG43DDnxT rsIt5LYSNnfJ5gvdtg0Bz7jZDaJltPCZITDdFXU3HuLeQl12etRnAYp0XrWrxis/B0 kvFEyjLzYCWdg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD3D1C27C53; Tue, 4 Jun 2024 06:29:59 +0000 (UTC) From: Joel Granados via B4 Relay Date: Tue, 04 Jun 2024 08:29:23 +0200 Subject: [PATCH 5/8] sysctl: Remove superfluous empty allocations from sysctl internals MIME-Version: 1.0 Message-Id: <20240604-jag-sysctl_remset-v1-5-2df7ecdba0bd@samsung.com> References: <20240604-jag-sysctl_remset-v1-0-2df7ecdba0bd@samsung.com> In-Reply-To: <20240604-jag-sysctl_remset-v1-0-2df7ecdba0bd@samsung.com> To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Suren Baghdasaryan , Kent Overstreet , Andrew Morton , Luis Chamberlain , Kees Cook , Joel Granados , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1905; i=j.granados@samsung.com; h=from:subject:message-id; bh=dykX5g3MqGx15MATEKwwLa2ClmbIRatln9uC2eazckc=; b=owJ4nAHtARL+kA0DAAoBupfNUreWQU8ByyZiAGZetGR3E2qjUjAS4q9w+HjZ+miKQrmluWXXn C0vkfATqOvX1okBswQAAQoAHRYhBK5HCVcl5jElzssnkLqXzVK3lkFPBQJmXrRkAAoJELqXzVK3 lkFPwCwL/jqnIEcEWutsOWB1UQTKFkNA7cz4uGlz1RuXDsLJxTehHd+yxHkXH/uC4QSeWlaJMhI y/M6hBaSMqyknpSMeXjgwML0myqcwanvUI52qQez7GuzEmaMStbuewJp4fIOopCHSV3fAefx++0 OYitv3k2B/txIQBpMqoHWgB9DejZcZzzB/KygVZrRs/vDrkWdIl5uMR3J/Ehw3MmcW+b2pU2os2 pXUQCyBxpa+rOAvWTm7MXOBOHZJnXlIKajR4RLbfGSvkNXJfLmHwY4XuCv2N9BXGX0RgCoMEYSM C5UiFki4U0ojWqyKLxg5Lj8T0XgxNjRvgtXo/ao/vdejeY7STem/sCXWVka8SWuXRY2YAFfBlcr mU7T+yqjI8JVf6MTCkQYPk9ueo5YHbqWt+oGCXPDUfFfELnkSsWHAsH0S782t4zi4XrmyP3bUZ9 KAkFDTj8PBaGvHxjxnIsU0ZxjNwxosVnynxuCAKNSU4szTgMzcl76Ck2/It8V8v3qnnHktCQJU7 uE= X-Developer-Key: i=j.granados@samsung.com; a=openpgp; fpr=F1F8E46D30F0F6C4A45FF4465895FAAC338C6E77 X-Endpoint-Received: by B4 Relay for j.granados@samsung.com/default with auth_id=70 X-Original-From: Joel Granados Reply-To: j.granados@samsung.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4562610000A X-Stat-Signature: uq646py5me78d8484c1nmkzh7jqa8yrs X-Rspam-User: X-HE-Tag: 1717482604-191443 X-HE-Meta: U2FsdGVkX1/TVtkCwvHA6dfP0RfjtEuQSvBkK1grkmRps2dr9aiD1vMD/OQNAlya/6pgNksIPFLbJAvpAIkxTdGcEQGkMvPdMfl4Wp8YCZ5BLDJ6hivcNzO+hOXQnnXR1fVlUYeVbmonslN7Sn5O4ONfnR+f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hC9cSqZ9BYg+rznTg2GYFBk3d54KHh4HTFTVrmZR6nfhAzm/rRGIZfnEg15lcSZKVRGejxezhI21fSnPjGBMhoxkn9wbUSm4sEdj4HA+QM3VsJutsh5vqoh0dDmDKW3phk2/YEtxWH1iUsH+I0A== 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: From: Joel Granados Now that the sentinels have been removed from ctl_table arrays, there is no need to artificially append empty ctl_table elements at ctl_table registration. Remove superfluous empty allocation from new_dir and new_links. Signed-off-by: Joel Granados --- fs/proc/proc_sysctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 1babb54347a4..29d40f0ff3ff 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -951,14 +951,14 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set, char *new_name; new = kzalloc(sizeof(*new) + sizeof(struct ctl_node) + - sizeof(struct ctl_table)*2 + namelen + 1, + sizeof(struct ctl_table) + namelen + 1, GFP_KERNEL); if (!new) return NULL; node = (struct ctl_node *)(new + 1); table = (struct ctl_table *)(node + 1); - new_name = (char *)(table + 2); + new_name = (char *)(table + 1); memcpy(new_name, name, namelen); table[0].procname = new_name; table[0].mode = S_IFDIR|S_IRUGO|S_IXUGO; @@ -1163,7 +1163,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ links = kzalloc(sizeof(struct ctl_table_header) + sizeof(struct ctl_node)*head->ctl_table_size + - sizeof(struct ctl_table)*(head->ctl_table_size + 1) + + sizeof(struct ctl_table)*head->ctl_table_size + name_bytes, GFP_KERNEL); @@ -1172,7 +1172,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table_ node = (struct ctl_node *)(links + 1); link_table = (struct ctl_table *)(node + head->ctl_table_size); - link_name = (char *)&link_table[head->ctl_table_size + 1]; + link_name = (char *)(link_table + head->ctl_table_size); link = link_table; list_for_each_table_entry(entry, head) {