Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2305278pxt; Sun, 8 Aug 2021 19:10:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYPAF8e8rc+CQC/2rpyamh2cB02T4NoZFgwqHwDSGP/l5aZxV/gVvbvq+jbm5eI3mW+MBn X-Received: by 2002:a05:6e02:f85:: with SMTP id v5mr282481ilo.289.1628475011415; Sun, 08 Aug 2021 19:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628475011; cv=none; d=google.com; s=arc-20160816; b=tRWhgIfVji1F8RtFX//dVkOPLHWZ43kUxWExPimQPCXCAPMlNmWa016V1rjRuT5DIK rCoul/SvX6goVLgtxidWFcje5F7JhHPEbmXXNYmg7UxQ5mpt7HgHPOfOxj5mEOYLD07m G2BnSzxkIbKKU2Qd1TiXEc9LXeOWASLJKGJTYhCHpVnmPAzk/66jTCKTcWEIkHEbIAU+ Wejj72KVwNSszoZkpHM9rI2rl+05fIWrknYQf2m+//zrLFV4jKCu24fPE8k8gQBuJVAe utRn8lgH4Z/m9GdzkVrD/DZ4F94p60Auv/wqI4P/Pa/DF6HhQPQ5OWIUqqFiU0je1msb a6DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=MKeRRmEFZM8hzagAYmFUTWjMruqDJIbN19rQLqjEMFU=; b=UApkit+tF73UB6CroQJ7HBs/U0RO7DIR4X50PUN5WIVXCOXfZE/ia1JA3VxyKb1osz QBTQdqnUkJYYdgtdd2TY1++DgP9y6+GWiMkCnL5LjqJZl1jAHs6PBTmjnpKlRzmyy0Cr xnuR4EKurqV9aqmojO8W2hZ0uW+WF12jcQsp/QrvsUZVCaKhrZ5x5TP/ewNqSt97uHE6 sI8aXbGiDnmYgFAVxB7mjvC7VbKe8PEhxU3lhOmFQyy/v1cCAzZcGHolMoF14DeBjuCK pzVDOYL4GjYU9PZeDZ4Yptbt9nMgXu3V/CCbJXwmX1QBRBVjiIlx3mHqu3HjcvGrWb5Z CQdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g7xD4hPu; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si17813648ilj.65.2021.08.08.19.10.00; Sun, 08 Aug 2021 19:10:11 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=g7xD4hPu; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232680AbhHICHf (ORCPT + 99 others); Sun, 8 Aug 2021 22:07:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58728 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231675AbhHICHe (ORCPT ); Sun, 8 Aug 2021 22:07:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628474835; h=from:from: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; bh=MKeRRmEFZM8hzagAYmFUTWjMruqDJIbN19rQLqjEMFU=; b=g7xD4hPurVm+4OoQKrgawn6Qscp9wx/uK5lY7fqYO6SXwvPZY+S+PRfF1zbpvGHIJaqlyn Ke4QwlzTcHYpBd39cf3AxDUofHFdo4O8/ZiLJ71pPuGfiR9zN9cBkGXdzYpxbTLrUcNJ7c gvw3VcWooWfkJRguDB7mVkmJ3OsDdnM= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-FugrKOBtPvq0Ugn_rR5UrQ-1; Sun, 08 Aug 2021 22:07:14 -0400 X-MC-Unique: FugrKOBtPvq0Ugn_rR5UrQ-1 Received: by mail-qt1-f200.google.com with SMTP id v28-20020a05622a189cb029028e697f617dso4885929qtc.20 for ; Sun, 08 Aug 2021 19:07:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MKeRRmEFZM8hzagAYmFUTWjMruqDJIbN19rQLqjEMFU=; b=KdQk4UeuvlYiuumzYlr9VVNZSG1kjAqSiNiBVOHvaDLIQ9oyTHIPvDqzMU+aeJ3075 P0ksnEDdsZww6yBL89kC77m1U2jY2y0si60djpNw+sxWquTi2kryiZ+m1HVSxJKV4cbM XHgJKJb/7x6AtpZa18QNaI1d0jm7c70/4HZZ2r1+4LcM/+jxsjsAnGiavrnkqR7yhpPu I4IJY2c8ESzWmkviwhqj9k2EkzZHlI5cEMvguA3hxdNHmwhV3Dkp+9f6jdZ/Zk6HeAHM YBxurUBaEXmWAEa5ZhdEGEDPyYWJ4HGzQupSE2SvzCFgIFlQgM9Eifu2heZLFIecNiAH 2CQw== X-Gm-Message-State: AOAM530L34BBNDHmXdW4B44t+zhR5C7lcbDg1c9RknUHYQvofZv7R1HR l9JbC2BPMC8bfQN7LjyoV/aDPqih47SUjxI2iOP35ZyYScnNoRm+YZAMCJXghZZRIpbrWkshGSD WjyOPFUbVm4uxuTW+cd8mfpQPCEQb2RUQQpsPrrL+O5VUa0T/c6sNaRLg81COL3qZ73r5lAEIsT 29 X-Received: by 2002:a37:ad0d:: with SMTP id f13mr3829044qkm.108.1628474833036; Sun, 08 Aug 2021 19:07:13 -0700 (PDT) X-Received: by 2002:a37:ad0d:: with SMTP id f13mr3829024qkm.108.1628474832788; Sun, 08 Aug 2021 19:07:12 -0700 (PDT) Received: from jtoppins.rdu.csb ([107.15.110.69]) by smtp.gmail.com with ESMTPSA id p13sm7851736qkk.87.2021.08.08.19.07.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Aug 2021 19:07:12 -0700 (PDT) Subject: Re: [PATCH net-next 2/2] bonding: combine netlink and console error messages To: Joe Perches , netdev@vger.kernel.org Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org References: <37c7bbbb01ede99974fc9ce3c3f5dad4845df9ee.camel@perches.com> <745ab8a85430ad4268a86b0957aa690c1a7a6d0f.camel@perches.com> From: Jonathan Toppins Message-ID: Date: Sun, 8 Aug 2021 22:07:11 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <745ab8a85430ad4268a86b0957aa690c1a7a6d0f.camel@perches.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/8/21 6:02 AM, Joe Perches wrote: > On Sat, 2021-08-07 at 17:54 -0400, Jonathan Toppins wrote: >> On 8/6/21 11:52 PM, Joe Perches wrote: >>> On Fri, 2021-08-06 at 23:30 -0400, Jonathan Toppins wrote: >>>> There seems to be no reason to have different error messages between >>>> netlink and printk. It also cleans up the function slightly. >>> [] >>>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c >>> [] >>>> +#define BOND_NL_ERR(bond_dev, extack, errmsg) do { \ >>>> + NL_SET_ERR_MSG(extack, errmsg); \ >>>> + netdev_err(bond_dev, "Error: " errmsg "\n"); \ >>>> +} while (0) >>>> + >>>> +#define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do { \ >>>> + NL_SET_ERR_MSG(extack, errmsg); \ >>>> + slave_err(bond_dev, slave_dev, "Error: " errmsg "\n"); \ >>>> +} while (0) >>> >>> If you are doing this, it's probably smaller object code to use >>> "%s", errmsg >>> as the errmsg string can be reused >>> >>> #define BOND_NL_ERR(bond_dev, extack, errmsg) \ >>> do { \ >>> NL_SET_ERR_MSG(extack, errmsg); \ >>> netdev_err(bond_dev, "Error: %s\n", errmsg); \ >>> } while (0) >>> >>> #define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) \ >>> do { \ >>> NL_SET_ERR_MSG(extack, errmsg); \ >>> slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg); \ >>> } while (0) >>> >>> >> >> I like the thought and would agree if not for how NL_SET_ERR_MSG is >> coded. Unfortunately it does not appear as though doing the above change >> actually generates smaller object code. Maybe I have incorrectly >> interpreted something? > > No, it's because you are compiling allyesconfig or equivalent. > Try defconfig with bonding. > > $ git clean -dxf $ git log -1 -p commit 8985f8d3fa38bca5f5384f9210ed735d58fd94f2 (HEAD -> upstream-bonding-cleanup) Author: Jonathan Toppins Date: Sun Aug 8 21:45:14 2021 -0400 object code optimization diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 46b95175690b..e2903ae7cdab 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1714,12 +1714,12 @@ void bond_lower_state_changed(struct slave *slave) #define BOND_NL_ERR(bond_dev, extack, errmsg) do { \ NL_SET_ERR_MSG(extack, errmsg); \ - netdev_err(bond_dev, "Error: " errmsg "\n"); \ + netdev_err(bond_dev, "Error: %s\n", errmsg); \ } while (0) #define SLAVE_NL_ERR(bond_dev, slave_dev, extack, errmsg) do { \ NL_SET_ERR_MSG(extack, errmsg); \ - slave_err(bond_dev, slave_dev, "Error: " errmsg "\n"); \ + slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg); \ } while (0) /* enslave device to bond device */ $ git log --oneline -2 8985f8d3fa38 (HEAD -> upstream-bonding-cleanup) object code optimization e326bf8fd30f bonding: combine netlink and console error messages $ make defconfig HOSTCC scripts/basic/fixdep [...] *** Default configuration is based on 'x86_64_defconfig' # # configuration written to .config # $ grep "BONDING" .config # CONFIG_BONDING is not set $ make menuconfig UPD scripts/kconfig/mconf-cfg [...] configuration written to .config *** End of the configuration. *** Execute 'make' to start the build or try 'make help'. $ grep "BONDING" .config CONFIG_BONDING=m $ git rebase -i --exec "make drivers/net/bonding/bond_main.o; ls -l drivers/net/bonding/bond_main.o" HEAD^^ Executing: make drivers/net/bonding/bond_main.o; ls -l drivers/net/bonding/bond_main.o SYNC include/config/auto.conf.cmd [...] CC /home/jtoppins/projects/linux-rhel7/tools/objtool/librbtree.o LD /home/jtoppins/projects/linux-rhel7/tools/objtool/objtool-in.o LINK /home/jtoppins/projects/linux-rhel7/tools/objtool/objtool CC [M] drivers/net/bonding/bond_main.o -rw-r--r--. 1 jtoppins jtoppins 131800 Aug 8 21:47 drivers/net/bonding/bond_main.o Executing: make drivers/net/bonding/bond_main.o; ls -l drivers/net/bonding/bond_main.o CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh DESCEND objtool CC [M] drivers/net/bonding/bond_main.o -rw-r--r--. 1 jtoppins jtoppins 131928 Aug 8 21:47 drivers/net/bonding/bond_main.o Successfully rebased and updated refs/heads/upstream-bonding-cleanup. $ gcc --version gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Jon