Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp482051pxu; Thu, 7 Jan 2021 09:44:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGWvt3M5QIP15IkBBUfx3RzCnlYsmgbZTIxeCy9lRgZyTeoUJJQAcCb1p/9AQkA6T3gG1/ X-Received: by 2002:a17:906:b7d6:: with SMTP id fy22mr7139683ejb.219.1610041459945; Thu, 07 Jan 2021 09:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610041459; cv=none; d=google.com; s=arc-20160816; b=n/5bvFmVmvitXqb2G6dUDz8VIkdCR9BPwwRWJJCz0n0CgxAsdfWOQkLhmJgn46NAr4 O5+5ua91CWhuvCGTtdNrEsFWKXZjOFdMm9UxApWCIdnKA69VqO3Ds462OVe5GBSqubFf tbJuNux0+1kP3ktxAnMrr3XGFikQUWkDqmgfxCoRpz3C9XGN0pT66kAvYQk6y15enjW5 J9n88JAyLdI5pYIZOUMajqhby81P4PNhM1lv8Lv9CSYCX04kSDJrv6jDf+aATHJTYb/Y yWOvaSOo1d/RSiosJ26x8tmWY04WGkag1pvchQ2QGRngWt/uCffsMbStxTs17uNDHoL0 Ey7Q== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ABCQzWYiHaTnr/nCJIoBspjfqat200PePG6cYjXON8g=; b=H99cF9Kbz05QCduhItVrW8fhf1eH+RPxmnIhzxiQHk3QO5KZeCxs32iE0gV8ZU0MEJ 7i5avPcCNM8PVoOKYSRoiHYRWaqu/9TrjtlVKJQK0z+jHcZQuIGO0ZKOf0CBPH8qkZ93 XtuJGoSwsnqLY0s7gD6aEILLQk0Gpu2E3z5AD6mbIMEtkhTD2Q2KU4HHiVX4JJmQdspY gHUaA4KqmToliND9+bDZV3aYGTfr15fC+ncE/EbBT4iFwdO7dJWxaZJK9T00WXg7UCZ/ bC/utoLAN0wratDJO7bC6bziR+SwR7cEck3OQCa3/jkoezSTPN1tQUxXWZrQt23xjZgU 8pXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G9fffMHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si2388923eja.462.2021.01.07.09.43.56; Thu, 07 Jan 2021 09:44:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G9fffMHk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729017AbhAGRm2 (ORCPT + 99 others); Thu, 7 Jan 2021 12:42:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:59284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbhAGRm1 (ORCPT ); Thu, 7 Jan 2021 12:42:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E1CC2233FD; Thu, 7 Jan 2021 17:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610041307; bh=2Y93tEVQ+bLJJTLclrFjB1a6L6zWPOSqbe/DcLT3KdU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=G9fffMHkznCZTdTkz+4dbp6BjFT1N/dEb/XrCK6KcOoIz2GSlkSovHYXrw9XDCizK lfk/fZC0AY2Hii2M9WgYqPZiEGfdF5b2t/BetPpfJNpw+JnSrg8o1kobYwMyRufQnr PF5eBSd2tcDEbd5zGSZLlM2giPlnNUAYBbnH1qrr9oooOSnGHcBJZ4/UXuEECSfN++ 1ADvAiuBjeEUQHHrXbz0uOM6lN0OAUP1kr91EESMKae9Db689QOR97cZx8pcCTxNtY vL8XdzCloRAm1C2O5r97F3dxvkXS4Yr0v/VBYt5K1WK+8Vtms7lz7dNpZQZyDhJqp1 BkibhSoslzngA== Date: Thu, 7 Jan 2021 09:41:46 -0800 From: Jakub Kicinski To: Alexander Lobakin Cc: "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: sysctl: cleanup net_sysctl_init() Message-ID: <20210107094146.37f20e69@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210107091318.2184-1-alobakin@pm.me> References: <20210106204014.34730-1-alobakin@pm.me> <20210106163056.79d75ffa@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20210107091318.2184-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 07 Jan 2021 09:13:40 +0000 Alexander Lobakin wrote: > From: Jakub Kicinski > Date: Wed, 6 Jan 2021 16:30:56 -0800 > > > On Wed, 06 Jan 2021 20:40:28 +0000 Alexander Lobakin wrote: > >> 'net_header' is not used outside of this function, so can be moved > >> from BSS onto the stack. > >> Declarations of one-element arrays are discouraged, and there's no > >> need to store 'empty' in BSS. Simply allocate it from heap at init. > > > > Are you sure? It's passed as an argument to register_sysctl() > > so it may well need to be valid for the lifetime of net_header. > > I just moved it from BSS to the heap and allocate it using kzalloc(), > it's still valid through the lifetime of the kernel. I see it now, please don't break the normal flow of error handling. What's the point of moving objects allocated in __init from BSS to the heap? If anything I'd think it'll take up more space when allocated in the heap because of the metadata that needs to be tracked for dynamic allocations. The move of net_header makes sense AFAICT, but we may have to annotate it somehow so kmemleak doesn't complain.