[PATCH v4 4/4] printk: use the lockless ringbuffer

kernel test robot lkp at intel.com
Tue Jul 7 15:25:00 EDT 2020


Hi John,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.8-rc4 next-20200707]
[cannot apply to pmladek/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/John-Ogness/printk-replace-ringbuffer/20200707-230114
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68
config: arm-randconfig-r014-20200707 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
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 arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

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

All warnings (new ones prefixed by >>):

>> kernel/printk/printk.c:1146:10: warning: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Wformat]
                          new_descs_size);
                          ^~~~~~~~~~~~~~
   include/linux/printk.h:338:33: note: expanded from macro 'pr_err'
           printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
                                  ~~~     ^~~~~~~~~~~
   1 warning generated.

vim +1146 kernel/printk/printk.c

  1090	
  1091	void __init setup_log_buf(int early)
  1092	{
  1093		unsigned int new_descs_count;
  1094		struct prb_desc *new_descs;
  1095		struct printk_info info;
  1096		struct printk_record r;
  1097		size_t new_descs_size;
  1098		unsigned long flags;
  1099		char *new_dict_buf;
  1100		char *new_log_buf;
  1101		unsigned int free;
  1102		u64 seq;
  1103	
  1104		/*
  1105		 * Some archs call setup_log_buf() multiple times - first is very
  1106		 * early, e.g. from setup_arch(), and second - when percpu_areas
  1107		 * are initialised.
  1108		 */
  1109		if (!early)
  1110			set_percpu_data_ready();
  1111	
  1112		if (log_buf != __log_buf)
  1113			return;
  1114	
  1115		if (!early && !new_log_buf_len)
  1116			log_buf_add_cpu();
  1117	
  1118		if (!new_log_buf_len)
  1119			return;
  1120	
  1121		new_descs_count = new_log_buf_len >> PRB_AVGBITS;
  1122		if (new_descs_count == 0) {
  1123			pr_err("new_log_buf_len: %lu too small\n", new_log_buf_len);
  1124			return;
  1125		}
  1126	
  1127		new_log_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN);
  1128		if (unlikely(!new_log_buf)) {
  1129			pr_err("log_buf_len: %lu text bytes not available\n",
  1130			       new_log_buf_len);
  1131			return;
  1132		}
  1133	
  1134		new_dict_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN);
  1135		if (unlikely(!new_dict_buf)) {
  1136			pr_err("log_buf_len: %lu dict bytes not available\n",
  1137			       new_log_buf_len);
  1138			memblock_free(__pa(new_log_buf), new_log_buf_len);
  1139			return;
  1140		}
  1141	
  1142		new_descs_size = new_descs_count * sizeof(struct prb_desc);
  1143		new_descs = memblock_alloc(new_descs_size, LOG_ALIGN);
  1144		if (unlikely(!new_descs)) {
  1145			pr_err("log_buf_len: %lu desc bytes not available\n",
> 1146			       new_descs_size);
  1147			memblock_free(__pa(new_dict_buf), new_log_buf_len);
  1148			memblock_free(__pa(new_log_buf), new_log_buf_len);
  1149			return;
  1150		}
  1151	
  1152		prb_rec_init_rd(&r, &info,
  1153				&setup_text_buf[0], sizeof(setup_text_buf),
  1154				&setup_dict_buf[0], sizeof(setup_dict_buf));
  1155	
  1156		prb_init(&printk_rb_dynamic,
  1157			 new_log_buf, order_base_2(new_log_buf_len),
  1158			 new_dict_buf, order_base_2(new_log_buf_len),
  1159			 new_descs, order_base_2(new_descs_count));
  1160	
  1161		logbuf_lock_irqsave(flags);
  1162	
  1163		log_buf_len = new_log_buf_len;
  1164		log_buf = new_log_buf;
  1165		new_log_buf_len = 0;
  1166	
  1167		free = __LOG_BUF_LEN;
  1168		prb_for_each_record(0, &printk_rb_static, seq, &r)
  1169			free -= add_to_rb(&printk_rb_dynamic, &r);
  1170	
  1171		/*
  1172		 * This is early enough that everything is still running on the
  1173		 * boot CPU and interrupts are disabled. So no new messages will
  1174		 * appear during the transition to the dynamic buffer.
  1175		 */
  1176		prb = &printk_rb_dynamic;
  1177	
  1178		logbuf_unlock_irqrestore(flags);
  1179	
  1180		if (seq != prb_next_seq(&printk_rb_static)) {
  1181			pr_err("dropped %llu messages\n",
  1182			       prb_next_seq(&printk_rb_static) - seq);
  1183		}
  1184	
  1185		pr_info("log_buf_len: %u bytes\n", log_buf_len);
  1186		pr_info("early log buf free: %u(%u%%)\n",
  1187			free, (free * 100) / __LOG_BUF_LEN);
  1188	}
  1189	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 33440 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kexec/attachments/20200708/fd1ea427/attachment-0001.gz>


More information about the kexec mailing list