Skip to contentSkip to conversation

lib: dynamic_queue_limits: use memset and offsetof init

PATCH In review Yejune Deng 1 participant 3 messages Jan 15, 2021 – Jan 16, 2021 1 message not in the archive Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: dynamic_queue_limits: use memset and offsetof init

In dql_reset(), use memset and offsetof instead of '= 0'.

---
 lib/dynamic_queue_limits.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
lib/dynamic_queue_limits.c +1 -7
index fde0aa2..21f0745 100644
@@ -116,13 +116,7 @@ void dql_completed(struct dql *dql, unsigned int count)
 void dql_reset(struct dql *dql)
 {
 	/* Reset all dynamic values */
-	dql->limit = 0;
-	dql->num_queued = 0;
-	dql->num_completed = 0;
-	dql->last_obj_cnt = 0;
-	dql->prev_num_queued = 0;
-	dql->prev_last_obj_cnt = 0;
-	dql->prev_ovlimit = 0;
+	memset(dql, 0, offsetof(struct dql, lowest_slack));
 	dql->lowest_slack = UINT_MAX;
 	dql->slack_start_time = jiffies;
 }
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

My patch is applied to linux-next/master tree.I also built in arch arm64 and x86_64,is OK.Is something wrong with that?

Quoted 58 lines · kernel test robot

Hi Yejune,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.11-rc3 next-20210114]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Yejune-Deng/lib-dynamic_queue_limits-use-memset-and-offsetof-init/20210115-112707
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 146620506274bd24d52fb1c589110a30eed8240b
config: nds32-randconfig-m031-20210115 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0

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
# https://github.com/0day-ci/linux/commit/9be25b076f67d15d29016cb613b95d2ae190a9b4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yejune-Deng/lib-dynamic_queue_limits-use-memset-and-offsetof-init/20210115-112707 git checkout 9be25b076f67d15d29016cb613b95d2ae190a9b4
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

lib/dynamic_queue_limits.c: In function 'dql_reset':

Quoted 1 line
Quoted 1 line

lib/dynamic_queue_limits.c:119:2: error: implicit declaration of function 'memset' [-Werror=implicit-function-declaration]

     119 |  memset(dql, 0, offsetof(struct dql, lowest_slack));
         |  ^~~~~~
Quoted 1 line
Quoted 1 line

lib/dynamic_queue_limits.c:119:2: warning: incompatible implicit declaration of built-in function 'memset'

lib/dynamic_queue_limits.c:11:1: note: include '<string.h>' or provide a declaration of 'memset'

      10 | #include <linux/dynamic_queue_limits.h>
     +++ |+#include <string.h>
      11 | #include <linux/compiler.h>

cc1: some warnings being treated as errors

vim +/memset +119 lib/dynamic_queue_limits.c

115
116 void dql_reset(struct dql *dql)
117 {

   118          /* Reset all dynamic values */
 > 119          memset(dql, 0, offsetof(struct dql, lowest_slack));
   120          dql->lowest_slack = UINT_MAX;
   121          dql->slack_start_time = jiffies;
   122  }
   123  EXPORT_SYMBOL(dql_reset);
   124

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#3 lore raw

Sorry.It failed in ARCH nds32,I will fix it in the next submit.

Quoted 63 lines · Yejune Deng

My patch is applied to linux-next/master tree.I also built in arch arm64 and x86_64,is OK.Is something wrong with that?

Quoted 58 lines · kernel test robot

Hi Yejune,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.11-rc3 next-20210114]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Yejune-Deng/lib-dynamic_queue_limits-use-memset-and-offsetof-init/20210115-112707
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 146620506274bd24d52fb1c589110a30eed8240b
config: nds32-randconfig-m031-20210115 (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.0

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
# https://github.com/0day-ci/linux/commit/9be25b076f67d15d29016cb613b95d2ae190a9b4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yejune-Deng/lib-dynamic_queue_limits-use-memset-and-offsetof-init/20210115-112707 git checkout 9be25b076f67d15d29016cb613b95d2ae190a9b4
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nds32

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

lib/dynamic_queue_limits.c: In function 'dql_reset':

Quoted 1 line
Quoted 1 line

lib/dynamic_queue_limits.c:119:2: error: implicit declaration of function 'memset' [-Werror=implicit-function-declaration]

     119 |  memset(dql, 0, offsetof(struct dql, lowest_slack));
         |  ^~~~~~
Quoted 1 line
Quoted 1 line

lib/dynamic_queue_limits.c:119:2: warning: incompatible implicit declaration of built-in function 'memset'

lib/dynamic_queue_limits.c:11:1: note: include '<string.h>' or provide a declaration of 'memset'

      10 | #include <linux/dynamic_queue_limits.h>
     +++ |+#include <string.h>
      11 | #include <linux/compiler.h>

cc1: some warnings being treated as errors

vim +/memset +119 lib/dynamic_queue_limits.c

115
116 void dql_reset(struct dql *dql)
117 {

   118          /* Reset all dynamic values */
 > 119          memset(dql, 0, offsetof(struct dql, lowest_slack));
   120          dql->lowest_slack = UINT_MAX;
   121          dql->slack_start_time = jiffies;
   122  }
   123  EXPORT_SYMBOL(dql_reset);
   124

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]