From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91C1AC33CAA for ; Thu, 23 Jan 2020 08:28:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62AFA24125 for ; Thu, 23 Jan 2020 08:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726191AbgAWI20 (ORCPT ); Thu, 23 Jan 2020 03:28:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:56322 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgAWI20 (ORCPT ); Thu, 23 Jan 2020 03:28:26 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9A7C2B1F7; Thu, 23 Jan 2020 08:28:24 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 50B5FE06F7; Thu, 23 Jan 2020 09:28:21 +0100 (CET) Date: Thu, 23 Jan 2020 09:28:21 +0100 From: Michal Kubecek To: netdev@vger.kernel.org Cc: Luigi Rizzo , Andrew Lunn , "David S. Miller" Subject: Re: [PATCH] net-core: remove unnecessary ETHTOOL_GCHANNELS initialization Message-ID: <20200123082821.GS22304@unicorn.suse.cz> References: <20200122223326.187954-1-lrizzo@google.com> <20200122234753.GA13647@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jan 22, 2020 at 04:18:56PM -0800, Luigi Rizzo wrote: > On Wed, Jan 22, 2020 at 3:47 PM Andrew Lunn wrote: > > > > On Wed, Jan 22, 2020 at 02:33:26PM -0800, Luigi Rizzo wrote: > > > struct ethtool_channels does not need .cmd to be set when calling the > > > driver's ethtool methods. Just zero-initialize it. > > > > > > Tested: run ethtool -l and ethtool -L > > > > Hi Luigi > > > > This seems pretty risky. You are assuming ethtool is the only user of > > this API. What is actually wrong with putting a sane cmd value, rather > > than the undefined value 0. > > Hi Andrew, if I understand correctly your suggestion is that even if > the values are unused, it is better to stay compliant with the header > file include/uapi/linux/ethtool.h, which does suggest a value for .cmd > for the various structs The point is that unless you check ethtool_ops::get_channels() of all in tree drivers, you cannot be sure there isn't one which depends on .cmd being set to expected value. And even then there could be some out of tree drivers; we usually don't care too much about those but it's always question of what you gain by the cleanup. AFAICS, in this case it might be few CPU cycles and even that isn't really sure. > and only replace the value in ethtool_set_channels() with the correct > one ETHTOOL_SCHANNELS ? That would be incorrect. In ethtool_set_channels(), the structure initialized is curr which is used with ->get_channels() to get current values (for comparison of new values against driver maximum) so that ETHTOOL_GCHANNELS is the right command. Michal