Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2044258rdb; Mon, 9 Oct 2023 10:34:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFg5nfFS5jeDKueU9VlxcytvfUNYAs9iIOx0PouW0YBDUFnuTxJFYh+9W9PLNOa05wQ//sd X-Received: by 2002:a17:903:120f:b0:1c7:5f03:8562 with SMTP id l15-20020a170903120f00b001c75f038562mr18959717plh.30.1696872887081; Mon, 09 Oct 2023 10:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696872887; cv=none; d=google.com; s=arc-20160816; b=zg9eXzkhg2SlBXJbLr6Nig0cAZPnvbq08+9ERHjKBujWhaXVx89waPj1hESEVu3wiT 4QolC71H8Cu5sFPfwongn8XggxrptpNJSa0PF6DGSm8V5oGr3zJT0UHB0YtM4cp/vZF1 HGp/def+3vk48kCuXLJOiXl4gb4vHd22HVWmKwbjDNE703ln8WHP5HmyY/SKZRn2I+Cu JN5g8Dgwjj8AH2AfFUkDtIhelppOMN/0fexqXjxBP2kARj1FraO0ZINd2MyVYzSWfB6u dR52FybmqiIALGkjlJUonU9LNH4AMYvsHDqxPihQxfg6QNi/kW5EolyWGwen1VOYawVM n6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Nq2GQ2H1vuKyNiZmrzLAFN/nNn6hx8PmFL/I895kOhs=; fh=AKxLGGflOkQ7YwU0i8NuZYP+Bkn4mzJHy4gmY/dcQOc=; b=b5H5FRGwIH4zKR7EHK89J+M9ufwSMVrOlwwptjpQggFPHVh6pYNRIssDxMFUw6SXNU X6QlGZ3AsgUbREPMld8WOPNaY7WE0Pvkeo5p4JlhnHMs1oCeOMd7sX8I5EIzJW7JDqXk /ooo2t+/Vo6GAYcoWVCI5w9wjYGH2MLCD5hrqyPZvBY4wzrYOAUVgp4Ir0iol+Fpsv13 /+rQfXsVCBwzKhbbmyNQNgwcdtHVK4Zv0vGDPO8Po2NuP+7d8MRW98dbYTJI0VJDtfLG 2etE3X1nwsjl7AR0/YVyrr2gWP8cXt4PrbEEHfDCvL/OxFASnQ78bT4uq1M7QoRoCl3d +dtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KJl6r+wN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id u7-20020a170903124700b001c589ba4a12si10573384plh.140.2023.10.09.10.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 10:34:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KJl6r+wN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 05342801B6E8; Mon, 9 Oct 2023 10:34:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377487AbjJIReZ (ORCPT + 99 others); Mon, 9 Oct 2023 13:34:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377975AbjJIReR (ORCPT ); Mon, 9 Oct 2023 13:34:17 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A112DF for ; Mon, 9 Oct 2023 10:34:15 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2c3e23a818bso16222941fa.0 for ; Mon, 09 Oct 2023 10:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1696872853; x=1697477653; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Nq2GQ2H1vuKyNiZmrzLAFN/nNn6hx8PmFL/I895kOhs=; b=KJl6r+wNby3JGHDV3gKCM1tx0/iaAAvTFAlmbgNXxX1LJk6GDoknrkNA32wMkWLOMd +CZ6WyFSh7ft0P8UpGMgtDP5TwDidZtnevFFyyALx2V2py/FFQszR0xrgUwW5gAeEkJ+ ucUsWTOOP78wRSogUhjBE3gvuk0xrPbsYIxG2lzAQiaV7MB43E559HFNDqSi3kuvjOrb +JnNgVAwPFlMBo0h61nmgqAkh29qayDVa7emtmxuISiJBDso7nUV2FFPdWmICMDKkFfd OEX5yf79Uz/TE+G/QTB09Hj5OdYXg2MZCicD2IQfLD5JzAGagM1S1jjPuRBE7xYqCL82 3UyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696872853; x=1697477653; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nq2GQ2H1vuKyNiZmrzLAFN/nNn6hx8PmFL/I895kOhs=; b=JNaw2XAz5v0fdAqPCSKXK0PWsfgOftqTYRuaxCxOeDoijq6kWeaU9clnv/PzmFwpQ9 x2UHkqrW4N2F5/taKIGYwXh5YwYUVj5bfZs8m6+yfRHwju3mZB0TVaYPgFX77Md3wg6/ p879/O4c9PaoKp02rQjotGTYjtxTZyvpLqVOC0C4aAxG15Lz9K0zTKa6P5e3+J1oy+eq ejFW/VH17d+e+28R7snZ6O6NkINNPXx+UTDJeEKlf4lVLE/b6Q32Mp4NXvKdqaAQtX0F zW+b33z5vVv78GorQcLqg1KVirtqTKjYxz1qkUCzyNJiPK9a35DbX2Nw0VlPi/MFHqym RHxg== X-Gm-Message-State: AOJu0Yz2S8cxIcN4OshUS6IeocUduXXYEfc/L8bux8y1FGNC4EjuEeWF fGWT+x4O+yZuNUDaxdcMB3q2pruIQL+scWkZfkPBnQ== X-Received: by 2002:a2e:870c:0:b0:2b6:cbdb:790c with SMTP id m12-20020a2e870c000000b002b6cbdb790cmr11318211lji.1.1696872853492; Mon, 09 Oct 2023 10:34:13 -0700 (PDT) MIME-Version: 1.0 References: <20231009165741.746184-1-max.kellermann@ionos.com> <20231009165741.746184-2-max.kellermann@ionos.com> <2023100908-pouring-synapse-75bd@gregkh> In-Reply-To: <2023100908-pouring-synapse-75bd@gregkh> From: Max Kellermann Date: Mon, 9 Oct 2023 19:34:02 +0200 Message-ID: Subject: Re: [PATCH 2/7] drivers/hwmon: add local variable for newly allocated attribute_group** To: Greg KH Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 10:34:45 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 9, 2023 at 7:27=E2=80=AFPM Greg KH wrote: > > On Mon, Oct 09, 2023 at 06:57:35PM +0200, Max Kellermann wrote: > > This allows the compiler to keep the pointer in a register and > > Maybe, maybe not, there's no guarantee for register usage. Agree. But without this change, register usage is effectively prevented (much of the time). With this change, there is a chance for better code. Yeah, it's not a critical code path, and it's only a tiny tiny optimization - but the real reason for this patch is .... > > - hwdev->groups =3D kcalloc(ngroups, sizeof(*groups), GFP_K= ERNEL); > > - if (!hwdev->groups) { > > + hwdev->groups =3D new_groups =3D kcalloc(ngroups, sizeof(= *new_groups), GFP_KERNEL); > > So you have a const pointer AND a non-const pointer pointing to the same > thing? .... so I can make "hwdev->groups" const, which wouldn't allow modifying it. (This isn't obvious in this one patch, but a later patch in the series does this.) There are only few functions which allocate a new pointer-array dynamically; all others are global variables which currently cannot be "const". This patch set does some lifting to allow adding "const".