All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit'
@ 2021-03-23  6:36 ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-03-23  6:36 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: kbuild-all, clang-built-linux, linux-kernel, Nathan Chancellor,
	Kees Cook, Andrew Morton, Linux Memory Management List

[-- Attachment #1: Type: text/plain, Size: 4740 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   84196390620ac0e5070ae36af84c137c6216a7dc
commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP*
date:   9 days ago
config: mips-randconfig-r023-20210322 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 78a65cd945d006ff02f9d24d9cc20a302ed93b08)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/chelsio/cxgb4/sge.c:814:28: warning: unused function 'calc_tx_descs' [-Wunused-function]
   static inline unsigned int calc_tx_descs(const struct sk_buff *skb,
                              ^
>> drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit' [-Wframe-larger-than=]
   static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
               ^
   2 warnings generated.


vim +/ethofld_xmit +2396 drivers/net/ethernet/chelsio/cxgb4/sge.c

4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2395  
4846d5330dafc8 Rahul Lakkireddy 2019-11-07 @2396  static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2397  {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2398  	struct sk_buff *skb;
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2399  	int pktcount, ret;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2400  
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2401  	switch (eosw_txq->state) {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2402  	case CXGB4_EO_STATE_ACTIVE:
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2403  	case CXGB4_EO_STATE_FLOWC_OPEN_SEND:
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2404  	case CXGB4_EO_STATE_FLOWC_CLOSE_SEND:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2405  		pktcount = eosw_txq->pidx - eosw_txq->last_pidx;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2406  		if (pktcount < 0)
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2407  			pktcount += eosw_txq->ndesc;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2408  		break;
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2409  	case CXGB4_EO_STATE_FLOWC_OPEN_REPLY:
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2410  	case CXGB4_EO_STATE_FLOWC_CLOSE_REPLY:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2411  	case CXGB4_EO_STATE_CLOSED:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2412  	default:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2413  		return;
272630feb4c0d2 Rahul Lakkireddy 2019-11-19  2414  	}
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2415  
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2416  	while (pktcount--) {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2417  		skb = eosw_txq_peek(eosw_txq);
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2418  		if (!skb) {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2419  			eosw_txq_advance_index(&eosw_txq->last_pidx, 1,
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2420  					       eosw_txq->ndesc);
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2421  			continue;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2422  		}
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2423  
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2424  		ret = ethofld_hard_xmit(dev, eosw_txq);
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2425  		if (ret)
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2426  			break;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2427  	}
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2428  }
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2429  

:::::: The code at line 2396 was first introduced by commit
:::::: 4846d5330dafc82990be7ffe1d1b383157268bd9 cxgb4: add Tx and Rx path for ETHOFLD traffic

:::::: TO: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33532 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit'
@ 2021-03-23  6:36 ` kernel test robot
  0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-03-23  6:36 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4821 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   84196390620ac0e5070ae36af84c137c6216a7dc
commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP*
date:   9 days ago
config: mips-randconfig-r023-20210322 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 78a65cd945d006ff02f9d24d9cc20a302ed93b08)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/chelsio/cxgb4/sge.c:814:28: warning: unused function 'calc_tx_descs' [-Wunused-function]
   static inline unsigned int calc_tx_descs(const struct sk_buff *skb,
                              ^
>> drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit' [-Wframe-larger-than=]
   static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
               ^
   2 warnings generated.


vim +/ethofld_xmit +2396 drivers/net/ethernet/chelsio/cxgb4/sge.c

4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2395  
4846d5330dafc8 Rahul Lakkireddy 2019-11-07 @2396  static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2397  {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2398  	struct sk_buff *skb;
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2399  	int pktcount, ret;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2400  
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2401  	switch (eosw_txq->state) {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2402  	case CXGB4_EO_STATE_ACTIVE:
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2403  	case CXGB4_EO_STATE_FLOWC_OPEN_SEND:
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2404  	case CXGB4_EO_STATE_FLOWC_CLOSE_SEND:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2405  		pktcount = eosw_txq->pidx - eosw_txq->last_pidx;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2406  		if (pktcount < 0)
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2407  			pktcount += eosw_txq->ndesc;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2408  		break;
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2409  	case CXGB4_EO_STATE_FLOWC_OPEN_REPLY:
0e395b3cb1fb82 Rahul Lakkireddy 2019-11-07  2410  	case CXGB4_EO_STATE_FLOWC_CLOSE_REPLY:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2411  	case CXGB4_EO_STATE_CLOSED:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2412  	default:
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2413  		return;
272630feb4c0d2 Rahul Lakkireddy 2019-11-19  2414  	}
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2415  
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2416  	while (pktcount--) {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2417  		skb = eosw_txq_peek(eosw_txq);
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2418  		if (!skb) {
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2419  			eosw_txq_advance_index(&eosw_txq->last_pidx, 1,
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2420  					       eosw_txq->ndesc);
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2421  			continue;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2422  		}
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2423  
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2424  		ret = ethofld_hard_xmit(dev, eosw_txq);
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2425  		if (ret)
4f1d97262d58e0 Rahul Lakkireddy 2020-05-15  2426  			break;
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2427  	}
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2428  }
4846d5330dafc8 Rahul Lakkireddy 2019-11-07  2429  

:::::: The code at line 2396 was first introduced by commit
:::::: 4846d5330dafc82990be7ffe1d1b383157268bd9 cxgb4: add Tx and Rx path for ETHOFLD traffic

:::::: TO: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33532 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit'
  2021-03-23  6:36 ` kernel test robot
  (?)
@ 2021-03-23  9:24   ` Arnd Bergmann
  -1 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-03-23  9:24 UTC (permalink / raw)
  To: kernel test robot
  Cc: kbuild-all, clang-built-linux, Linux Kernel Mailing List,
	Nathan Chancellor, Kees Cook, Andrew Morton,
	Linux Memory Management List

On Tue, Mar 23, 2021 at 7:37 AM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   84196390620ac0e5070ae36af84c137c6216a7dc
> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP*
> date:   9 days ago
> config: mips-randconfig-r023-20210322 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 78a65cd945d006ff02f9d24d9cc20a302ed93b08)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install mips cross compiling tool for clang build
>         # apt-get install binutils-mips-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
>    drivers/net/ethernet/chelsio/cxgb4/sge.c:814:28: warning: unused function 'calc_tx_descs' [-Wunused-function]
>    static inline unsigned int calc_tx_descs(const struct sk_buff *skb,
>                               ^
> >> drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit' [-Wframe-larger-than=]
>    static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
>                ^
>    2 warnings generated.

This looks related to a warning we saw on powerpc. I've tried digging
into it a little
bit more, but all I found is that the use of __builtin_bswap32() changes the
inlining decisions but doesn't actively cause worse code.

In fact, if I force the inlining like this:

--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2257,7 +2257,7 @@ static void *write_eo_wr(struct adapter *adap,
struct sge_eosw_txq *eosw_txq,
        return cpl;
 }

-static int ethofld_hard_xmit(struct net_device *dev,
+static __attribute__((flatten)) __always_inline int
ethofld_hard_xmit(struct net_device *dev,
                             struct sge_eosw_txq *eosw_txq)
 {
        struct port_info *pi = netdev2pinfo(dev);
@@ -2393,7 +2393,7 @@ static int ethofld_hard_xmit(struct net_device *dev,
        return ret;
 }

-static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
+static noinline void ethofld_xmit(struct net_device *dev, struct
sge_eosw_txq *eosw_txq)
 {
        struct sk_buff *skb;
        int pktcount, ret;

I see a different effect: the function's frame grows to 2232 bytes with the
open-coded bswap32 slightly less at 2200 bytes with the builtin bswap32,
all because of too many variables getting spilled.

On the other hand, marking ethofld_hard_xmit as flatten+noinline, I don't
get these spills with either version of bswap32, and the stack usage of
ethofld_hard_xmit()/ethofld_xmit() goes down to 472+112 bytes.

If I remove -fsanitize=alignment, the total stack size for these functions is
no more than 368 bytes regardless of the inlining or the bswap32()
implementation.

I would conclude that there is something wrong in clang that leads to badly
optimized code in this file, but that my __builtin_bswap32() change is only
what triggers the right conditions here, not the root cause.

        Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit'
@ 2021-03-23  9:24   ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-03-23  9:24 UTC (permalink / raw)
  To: kernel test robot
  Cc: kbuild-all, clang-built-linux, Linux Kernel Mailing List,
	Nathan Chancellor, Kees Cook, Andrew Morton,
	Linux Memory Management List

On Tue, Mar 23, 2021 at 7:37 AM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   84196390620ac0e5070ae36af84c137c6216a7dc
> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP*
> date:   9 days ago
> config: mips-randconfig-r023-20210322 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 78a65cd945d006ff02f9d24d9cc20a302ed93b08)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install mips cross compiling tool for clang build
>         # apt-get install binutils-mips-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
>    drivers/net/ethernet/chelsio/cxgb4/sge.c:814:28: warning: unused function 'calc_tx_descs' [-Wunused-function]
>    static inline unsigned int calc_tx_descs(const struct sk_buff *skb,
>                               ^
> >> drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit' [-Wframe-larger-than=]
>    static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
>                ^
>    2 warnings generated.

This looks related to a warning we saw on powerpc. I've tried digging
into it a little
bit more, but all I found is that the use of __builtin_bswap32() changes the
inlining decisions but doesn't actively cause worse code.

In fact, if I force the inlining like this:

--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2257,7 +2257,7 @@ static void *write_eo_wr(struct adapter *adap,
struct sge_eosw_txq *eosw_txq,
        return cpl;
 }

-static int ethofld_hard_xmit(struct net_device *dev,
+static __attribute__((flatten)) __always_inline int
ethofld_hard_xmit(struct net_device *dev,
                             struct sge_eosw_txq *eosw_txq)
 {
        struct port_info *pi = netdev2pinfo(dev);
@@ -2393,7 +2393,7 @@ static int ethofld_hard_xmit(struct net_device *dev,
        return ret;
 }

-static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
+static noinline void ethofld_xmit(struct net_device *dev, struct
sge_eosw_txq *eosw_txq)
 {
        struct sk_buff *skb;
        int pktcount, ret;

I see a different effect: the function's frame grows to 2232 bytes with the
open-coded bswap32 slightly less at 2200 bytes with the builtin bswap32,
all because of too many variables getting spilled.

On the other hand, marking ethofld_hard_xmit as flatten+noinline, I don't
get these spills with either version of bswap32, and the stack usage of
ethofld_hard_xmit()/ethofld_xmit() goes down to 472+112 bytes.

If I remove -fsanitize=alignment, the total stack size for these functions is
no more than 368 bytes regardless of the inlining or the bswap32()
implementation.

I would conclude that there is something wrong in clang that leads to badly
optimized code in this file, but that my __builtin_bswap32() change is only
what triggers the right conditions here, not the root cause.

        Arnd


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit'
@ 2021-03-23  9:24   ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-03-23  9:24 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3891 bytes --]

On Tue, Mar 23, 2021 at 7:37 AM kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   84196390620ac0e5070ae36af84c137c6216a7dc
> commit: 97e4910232fa1f81e806aa60c25a0450276d99a2 linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP*
> date:   9 days ago
> config: mips-randconfig-r023-20210322 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 78a65cd945d006ff02f9d24d9cc20a302ed93b08)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install mips cross compiling tool for clang build
>         # apt-get install binutils-mips-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=97e4910232fa1f81e806aa60c25a0450276d99a2
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 97e4910232fa1f81e806aa60c25a0450276d99a2
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
>    drivers/net/ethernet/chelsio/cxgb4/sge.c:814:28: warning: unused function 'calc_tx_descs' [-Wunused-function]
>    static inline unsigned int calc_tx_descs(const struct sk_buff *skb,
>                               ^
> >> drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit' [-Wframe-larger-than=]
>    static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
>                ^
>    2 warnings generated.

This looks related to a warning we saw on powerpc. I've tried digging
into it a little
bit more, but all I found is that the use of __builtin_bswap32() changes the
inlining decisions but doesn't actively cause worse code.

In fact, if I force the inlining like this:

--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2257,7 +2257,7 @@ static void *write_eo_wr(struct adapter *adap,
struct sge_eosw_txq *eosw_txq,
        return cpl;
 }

-static int ethofld_hard_xmit(struct net_device *dev,
+static __attribute__((flatten)) __always_inline int
ethofld_hard_xmit(struct net_device *dev,
                             struct sge_eosw_txq *eosw_txq)
 {
        struct port_info *pi = netdev2pinfo(dev);
@@ -2393,7 +2393,7 @@ static int ethofld_hard_xmit(struct net_device *dev,
        return ret;
 }

-static void ethofld_xmit(struct net_device *dev, struct sge_eosw_txq *eosw_txq)
+static noinline void ethofld_xmit(struct net_device *dev, struct
sge_eosw_txq *eosw_txq)
 {
        struct sk_buff *skb;
        int pktcount, ret;

I see a different effect: the function's frame grows to 2232 bytes with the
open-coded bswap32 slightly less at 2200 bytes with the builtin bswap32,
all because of too many variables getting spilled.

On the other hand, marking ethofld_hard_xmit as flatten+noinline, I don't
get these spills with either version of bswap32, and the stack usage of
ethofld_hard_xmit()/ethofld_xmit() goes down to 472+112 bytes.

If I remove -fsanitize=alignment, the total stack size for these functions is
no more than 368 bytes regardless of the inlining or the bswap32()
implementation.

I would conclude that there is something wrong in clang that leads to badly
optimized code in this file, but that my __builtin_bswap32() change is only
what triggers the right conditions here, not the root cause.

        Arnd

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-23  9:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23  6:36 drivers/net/ethernet/chelsio/cxgb4/sge.c:2396:13: warning: stack frame size of 1168 bytes in function 'ethofld_xmit' kernel test robot
2021-03-23  6:36 ` kernel test robot
2021-03-23  9:24 ` Arnd Bergmann
2021-03-23  9:24   ` Arnd Bergmann
2021-03-23  9:24   ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.