diff mbox series

[v4,14/24] dept: Apply SDT to swait

Message ID 1646377603-19730-15-git-send-email-byungchul.park@lge.com
State New
Headers show
Series DEPT(Dependency Tracker) | expand

Commit Message

Byungchul Park March 4, 2022, 7:06 a.m. UTC
Makes SDT able to track dependencies by swait.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 include/linux/swait.h |  4 ++++
 kernel/sched/swait.c  | 10 ++++++++++
 2 files changed, 14 insertions(+)

Comments

kernel test robot March 9, 2022, 9:14 a.m. UTC | #1
Hi Byungchul,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on linux/master linus/master v5.17-rc7]
[cannot apply to tip/locking/core hnaz-mm/master next-20220308]
[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/Byungchul-Park/DEPT-Dependency-Tracker/20220304-150943
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 25795ef6299f07ce3838f3253a9cb34f64efcfae
config: hexagon-randconfig-r022-20220307 (https://download.01.org/0day-ci/archive/20220309/202203091736.ZSni5gJV-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
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/dbdd22ef0f5b79f561dc8766d253b10b496c0091
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Byungchul-Park/DEPT-Dependency-Tracker/20220304-150943
        git checkout dbdd22ef0f5b79f561dc8766d253b10b496c0091
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/target/

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/target/target_core_xcopy.c:667:13: warning: stack frame size (1064) exceeds limit (1024) in 'target_xcopy_do_work' [-Wframe-larger-than]
   static void target_xcopy_do_work(struct work_struct *work)
               ^
   1 warning generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for FRAME_POINTER
   Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
   Selected by
   - DEPT && DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT && !MIPS && !PPC && !ARM && !S390 && !MICROBLAZE && !ARC && !X86


vim +/target_xcopy_do_work +667 drivers/target/target_core_xcopy.c

cbf031f425fd0b Nicholas Bellinger 2013-08-20  666  
cbf031f425fd0b Nicholas Bellinger 2013-08-20 @667  static void target_xcopy_do_work(struct work_struct *work)
cbf031f425fd0b Nicholas Bellinger 2013-08-20  668  {
cbf031f425fd0b Nicholas Bellinger 2013-08-20  669  	struct xcopy_op *xop = container_of(work, struct xcopy_op, xop_work);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  670  	struct se_cmd *ec_cmd = xop->xop_se_cmd;
d877d7275be34a Bart Van Assche    2017-05-23  671  	struct se_device *src_dev, *dst_dev;
d877d7275be34a Bart Van Assche    2017-05-23  672  	sector_t src_lba, dst_lba, end_lba;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  673  	unsigned int max_sectors;
d877d7275be34a Bart Van Assche    2017-05-23  674  	int rc = 0;
0ad08996da05b6 David Disseldorp   2020-03-27  675  	unsigned short nolb, max_nolb, copied_nolb = 0;
0394b5048efd73 Sergey Samoylenko  2021-08-03  676  	sense_reason_t sense_rc;
d877d7275be34a Bart Van Assche    2017-05-23  677  
0394b5048efd73 Sergey Samoylenko  2021-08-03  678  	sense_rc = target_parse_xcopy_cmd(xop);
0394b5048efd73 Sergey Samoylenko  2021-08-03  679  	if (sense_rc != TCM_NO_SENSE)
d877d7275be34a Bart Van Assche    2017-05-23  680  		goto err_free;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  681  
0394b5048efd73 Sergey Samoylenko  2021-08-03  682  	if (WARN_ON_ONCE(!xop->src_dev) || WARN_ON_ONCE(!xop->dst_dev)) {
0394b5048efd73 Sergey Samoylenko  2021-08-03  683  		sense_rc = TCM_INVALID_PARAMETER_LIST;
d877d7275be34a Bart Van Assche    2017-05-23  684  		goto err_free;
0394b5048efd73 Sergey Samoylenko  2021-08-03  685  	}
d877d7275be34a Bart Van Assche    2017-05-23  686  
d877d7275be34a Bart Van Assche    2017-05-23  687  	src_dev = xop->src_dev;
d877d7275be34a Bart Van Assche    2017-05-23  688  	dst_dev = xop->dst_dev;
d877d7275be34a Bart Van Assche    2017-05-23  689  	src_lba = xop->src_lba;
d877d7275be34a Bart Van Assche    2017-05-23  690  	dst_lba = xop->dst_lba;
d877d7275be34a Bart Van Assche    2017-05-23  691  	nolb = xop->nolb;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  692  	end_lba = src_lba + nolb;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  693  	/*
cbf031f425fd0b Nicholas Bellinger 2013-08-20  694  	 * Break up XCOPY I/O into hw_max_sectors sized I/O based on the
cbf031f425fd0b Nicholas Bellinger 2013-08-20  695  	 * smallest max_sectors between src_dev + dev_dev, or
cbf031f425fd0b Nicholas Bellinger 2013-08-20  696  	 */
cbf031f425fd0b Nicholas Bellinger 2013-08-20  697  	max_sectors = min(src_dev->dev_attrib.hw_max_sectors,
cbf031f425fd0b Nicholas Bellinger 2013-08-20  698  			  dst_dev->dev_attrib.hw_max_sectors);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  699  	max_sectors = min_t(u32, max_sectors, XCOPY_MAX_SECTORS);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  700  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  701  	max_nolb = min_t(u16, max_sectors, ((u16)(~0U)));
cbf031f425fd0b Nicholas Bellinger 2013-08-20  702  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  703  	pr_debug("target_xcopy_do_work: nolb: %hu, max_nolb: %hu end_lba: %llu\n",
cbf031f425fd0b Nicholas Bellinger 2013-08-20  704  			nolb, max_nolb, (unsigned long long)end_lba);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  705  	pr_debug("target_xcopy_do_work: Starting src_lba: %llu, dst_lba: %llu\n",
cbf031f425fd0b Nicholas Bellinger 2013-08-20  706  			(unsigned long long)src_lba, (unsigned long long)dst_lba);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  707  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  708  	while (src_lba < end_lba) {
0ad08996da05b6 David Disseldorp   2020-03-27  709  		unsigned short cur_nolb = min(nolb, max_nolb);
0ad08996da05b6 David Disseldorp   2020-03-27  710  		u32 cur_bytes = cur_nolb * src_dev->dev_attrib.block_size;
0ad08996da05b6 David Disseldorp   2020-03-27  711  
0ad08996da05b6 David Disseldorp   2020-03-27  712  		if (cur_bytes != xop->xop_data_bytes) {
0ad08996da05b6 David Disseldorp   2020-03-27  713  			/*
0ad08996da05b6 David Disseldorp   2020-03-27  714  			 * (Re)allocate a buffer large enough to hold the XCOPY
0ad08996da05b6 David Disseldorp   2020-03-27  715  			 * I/O size, which can be reused each read / write loop.
0ad08996da05b6 David Disseldorp   2020-03-27  716  			 */
0ad08996da05b6 David Disseldorp   2020-03-27  717  			target_free_sgl(xop->xop_data_sg, xop->xop_data_nents);
0ad08996da05b6 David Disseldorp   2020-03-27  718  			rc = target_alloc_sgl(&xop->xop_data_sg,
0ad08996da05b6 David Disseldorp   2020-03-27  719  					      &xop->xop_data_nents,
0ad08996da05b6 David Disseldorp   2020-03-27  720  					      cur_bytes,
0ad08996da05b6 David Disseldorp   2020-03-27  721  					      false, false);
0ad08996da05b6 David Disseldorp   2020-03-27  722  			if (rc < 0)
0ad08996da05b6 David Disseldorp   2020-03-27  723  				goto out;
0ad08996da05b6 David Disseldorp   2020-03-27  724  			xop->xop_data_bytes = cur_bytes;
0ad08996da05b6 David Disseldorp   2020-03-27  725  		}
cbf031f425fd0b Nicholas Bellinger 2013-08-20  726  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  727  		pr_debug("target_xcopy_do_work: Calling read src_dev: %p src_lba: %llu,"
cbf031f425fd0b Nicholas Bellinger 2013-08-20  728  			" cur_nolb: %hu\n", src_dev, (unsigned long long)src_lba, cur_nolb);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  729  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  730  		rc = target_xcopy_read_source(ec_cmd, xop, src_dev, src_lba, cur_nolb);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  731  		if (rc < 0)
cbf031f425fd0b Nicholas Bellinger 2013-08-20  732  			goto out;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  733  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  734  		src_lba += cur_nolb;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  735  		pr_debug("target_xcopy_do_work: Incremented READ src_lba to %llu\n",
cbf031f425fd0b Nicholas Bellinger 2013-08-20  736  				(unsigned long long)src_lba);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  737  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  738  		pr_debug("target_xcopy_do_work: Calling write dst_dev: %p dst_lba: %llu,"
cbf031f425fd0b Nicholas Bellinger 2013-08-20  739  			" cur_nolb: %hu\n", dst_dev, (unsigned long long)dst_lba, cur_nolb);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  740  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  741  		rc = target_xcopy_write_destination(ec_cmd, xop, dst_dev,
cbf031f425fd0b Nicholas Bellinger 2013-08-20  742  						dst_lba, cur_nolb);
b92fcfcb687de7 David Disseldorp   2020-03-27  743  		if (rc < 0)
cbf031f425fd0b Nicholas Bellinger 2013-08-20  744  			goto out;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  745  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  746  		dst_lba += cur_nolb;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  747  		pr_debug("target_xcopy_do_work: Incremented WRITE dst_lba to %llu\n",
cbf031f425fd0b Nicholas Bellinger 2013-08-20  748  				(unsigned long long)dst_lba);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  749  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  750  		copied_nolb += cur_nolb;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  751  		nolb -= cur_nolb;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  752  	}
cbf031f425fd0b Nicholas Bellinger 2013-08-20  753  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  754  	xcopy_pt_undepend_remotedev(xop);
0ad08996da05b6 David Disseldorp   2020-03-27  755  	target_free_sgl(xop->xop_data_sg, xop->xop_data_nents);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  756  	kfree(xop);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  757  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  758  	pr_debug("target_xcopy_do_work: Final src_lba: %llu, dst_lba: %llu\n",
cbf031f425fd0b Nicholas Bellinger 2013-08-20  759  		(unsigned long long)src_lba, (unsigned long long)dst_lba);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  760  	pr_debug("target_xcopy_do_work: Blocks copied: %hu, Bytes Copied: %u\n",
cbf031f425fd0b Nicholas Bellinger 2013-08-20  761  		copied_nolb, copied_nolb * dst_dev->dev_attrib.block_size);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  762  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  763  	pr_debug("target_xcopy_do_work: Setting X-COPY GOOD status -> sending response\n");
cbf031f425fd0b Nicholas Bellinger 2013-08-20  764  	target_complete_cmd(ec_cmd, SAM_STAT_GOOD);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  765  	return;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  766  
cbf031f425fd0b Nicholas Bellinger 2013-08-20  767  out:
0394b5048efd73 Sergey Samoylenko  2021-08-03  768  	/*
0394b5048efd73 Sergey Samoylenko  2021-08-03  769  	 * The XCOPY command was aborted after some data was transferred.
0394b5048efd73 Sergey Samoylenko  2021-08-03  770  	 * Terminate command with CHECK CONDITION status, with the sense key
0394b5048efd73 Sergey Samoylenko  2021-08-03  771  	 * set to COPY ABORTED.
0394b5048efd73 Sergey Samoylenko  2021-08-03  772  	 */
0394b5048efd73 Sergey Samoylenko  2021-08-03  773  	sense_rc = TCM_COPY_TARGET_DEVICE_NOT_REACHABLE;
cbf031f425fd0b Nicholas Bellinger 2013-08-20  774  	xcopy_pt_undepend_remotedev(xop);
0ad08996da05b6 David Disseldorp   2020-03-27  775  	target_free_sgl(xop->xop_data_sg, xop->xop_data_nents);
d877d7275be34a Bart Van Assche    2017-05-23  776  
d877d7275be34a Bart Van Assche    2017-05-23  777  err_free:
cbf031f425fd0b Nicholas Bellinger 2013-08-20  778  	kfree(xop);
0394b5048efd73 Sergey Samoylenko  2021-08-03  779  	pr_warn_ratelimited("target_xcopy_do_work: rc: %d, sense: %u, XCOPY operation failed\n",
0394b5048efd73 Sergey Samoylenko  2021-08-03  780  			   rc, sense_rc);
0394b5048efd73 Sergey Samoylenko  2021-08-03  781  	target_complete_cmd_with_sense(ec_cmd, SAM_STAT_CHECK_CONDITION, sense_rc);
cbf031f425fd0b Nicholas Bellinger 2013-08-20  782  }
cbf031f425fd0b Nicholas Bellinger 2013-08-20  783  

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

Patch

diff --git a/include/linux/swait.h b/include/linux/swait.h
index 6a8c22b..dbdf2ce 100644
--- a/include/linux/swait.h
+++ b/include/linux/swait.h
@@ -6,6 +6,7 @@ 
 #include <linux/stddef.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
+#include <linux/dept_sdt.h>
 #include <asm/current.h>
 
 /*
@@ -43,6 +44,7 @@ 
 struct swait_queue_head {
 	raw_spinlock_t		lock;
 	struct list_head	task_list;
+	struct dept_map		dmap;
 };
 
 struct swait_queue {
@@ -61,6 +63,7 @@  struct swait_queue {
 #define __SWAIT_QUEUE_HEAD_INITIALIZER(name) {				\
 	.lock		= __RAW_SPIN_LOCK_UNLOCKED(name.lock),		\
 	.task_list	= LIST_HEAD_INIT((name).task_list),		\
+	.dmap		= DEPT_SDT_MAP_INIT(name),			\
 }
 
 #define DECLARE_SWAIT_QUEUE_HEAD(name)					\
@@ -72,6 +75,7 @@  extern void __init_swait_queue_head(struct swait_queue_head *q, const char *name
 #define init_swait_queue_head(q)				\
 	do {							\
 		static struct lock_class_key __key;		\
+		sdt_map_init(&(q)->dmap);			\
 		__init_swait_queue_head((q), #q, &__key);	\
 	} while (0)
 
diff --git a/kernel/sched/swait.c b/kernel/sched/swait.c
index e1c655f..4ca7d6e 100644
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
@@ -27,6 +27,7 @@  void swake_up_locked(struct swait_queue_head *q)
 		return;
 
 	curr = list_first_entry(&q->task_list, typeof(*curr), task_list);
+	sdt_event(&q->dmap);
 	wake_up_process(curr->task);
 	list_del_init(&curr->task_list);
 }
@@ -69,6 +70,7 @@  void swake_up_all(struct swait_queue_head *q)
 	while (!list_empty(&tmp)) {
 		curr = list_first_entry(&tmp, typeof(*curr), task_list);
 
+		sdt_event(&q->dmap);
 		wake_up_state(curr->task, TASK_NORMAL);
 		list_del_init(&curr->task_list);
 
@@ -97,6 +99,9 @@  void prepare_to_swait_exclusive(struct swait_queue_head *q, struct swait_queue *
 	__prepare_to_swait(q, wait);
 	set_current_state(state);
 	raw_spin_unlock_irqrestore(&q->lock, flags);
+
+	if (state & TASK_NORMAL)
+		sdt_wait_prepare(&q->dmap);
 }
 EXPORT_SYMBOL(prepare_to_swait_exclusive);
 
@@ -119,12 +124,16 @@  long prepare_to_swait_event(struct swait_queue_head *q, struct swait_queue *wait
 	}
 	raw_spin_unlock_irqrestore(&q->lock, flags);
 
+	if (!ret && state & TASK_NORMAL)
+		sdt_wait_prepare(&q->dmap);
+
 	return ret;
 }
 EXPORT_SYMBOL(prepare_to_swait_event);
 
 void __finish_swait(struct swait_queue_head *q, struct swait_queue *wait)
 {
+	sdt_wait_finish();
 	__set_current_state(TASK_RUNNING);
 	if (!list_empty(&wait->task_list))
 		list_del_init(&wait->task_list);
@@ -134,6 +143,7 @@  void finish_swait(struct swait_queue_head *q, struct swait_queue *wait)
 {
 	unsigned long flags;
 
+	sdt_wait_finish();
 	__set_current_state(TASK_RUNNING);
 
 	if (!list_empty_careful(&wait->task_list)) {