Re: [PATCH] Add a file named cgroup.procs_stat in cgroup (fwd)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The lock taken at the beginning of the function is released at the end of
the function, so it would seem that it should be released on the error
path as well.

julia

---------- Forwarded message ----------
Date: Sat, 5 May 2018 14:46:14 +0800
From: kbuild test robot <lkp@xxxxxxxxx>
To: kbuild@xxxxxx
Cc: Julia Lawall <julia.lawall@xxxxxxx>
Subject: Re: [PATCH] Add a file named cgroup.procs_stat in cgroup

CC: kbuild-all@xxxxxx
In-Reply-To: <1525444100-4858-1-git-send-email-qiangzh.hust@xxxxxxxxx>
References: <1525444100-4858-1-git-send-email-qiangzh.hust@xxxxxxxxx>

Hi zhangq95,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.17-rc3]
[cannot apply to cgroup/for-next next-20180504]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/zhangq95/Add-a-file-named-cgroup-procs_stat-in-cgroup/20180505-115518
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago

>> kernel/cgroup/cgroup-v1.c:634:3-9: preceding lock on line 626

# https://github.com/0day-ci/linux/commit/9f9752597b186297099a85b9a33fbc85d132e7c6
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 9f9752597b186297099a85b9a33fbc85d132e7c6
vim +634 kernel/cgroup/cgroup-v1.c

0a268dbd Tejun Heo 2016-12-27  609
9f975259 zhangq95  2018-05-04  610  static int cgroup_procs_stat_show(struct seq_file *s, void *v)
9f975259 zhangq95  2018-05-04  611  {
9f975259 zhangq95  2018-05-04  612  	struct kernfs_open_file *of = s->private;
9f975259 zhangq95  2018-05-04  613  	struct cgroup *cgrp = seq_css(s)->cgroup;
9f975259 zhangq95  2018-05-04  614  	struct cgroup_pidlist *l;
9f975259 zhangq95  2018-05-04  615  	enum cgroup_filetype type = seq_cft(s)->private;
9f975259 zhangq95  2018-05-04  616  	struct task_struct *tsk;
9f975259 zhangq95  2018-05-04  617  	int ret, i = 0, j = 0, tmp = 0;
9f975259 zhangq95  2018-05-04  618  	unsigned long forks = 0, iowait = 0, nr_runnable = 0;
9f975259 zhangq95  2018-05-04  619  	pid_t *start;
9f975259 zhangq95  2018-05-04  620  	struct timespec64 boottime;
9f975259 zhangq95  2018-05-04  621  	unsigned long long start_time, switches = 0;
9f975259 zhangq95  2018-05-04  622  	unsigned long per_softirq_nums[NR_SOFTIRQS] = {0};
9f975259 zhangq95  2018-05-04  623  	unsigned long sum_softirq = 0;
9f975259 zhangq95  2018-05-04  624  	struct cpumask cpus_allowed;
9f975259 zhangq95  2018-05-04  625
9f975259 zhangq95  2018-05-04 @626  	mutex_lock(&cgrp->pidlist_mutex);
9f975259 zhangq95  2018-05-04  627  	if (of->priv)
9f975259 zhangq95  2018-05-04  628  		of->priv = cgroup_pidlist_find(cgrp, type);
9f975259 zhangq95  2018-05-04  629
9f975259 zhangq95  2018-05-04  630  	if (!of->priv) {
9f975259 zhangq95  2018-05-04  631  		ret = pidlist_array_load(cgrp, type,
9f975259 zhangq95  2018-05-04  632  					 (struct cgroup_pidlist **)&of->priv);
9f975259 zhangq95  2018-05-04  633  		if (ret)
9f975259 zhangq95  2018-05-04 @634  			return ERR_PTR(ret);
9f975259 zhangq95  2018-05-04  635  	}
9f975259 zhangq95  2018-05-04  636  	l = of->priv;
9f975259 zhangq95  2018-05-04  637
9f975259 zhangq95  2018-05-04  638  	start = l->list;
9f975259 zhangq95  2018-05-04  639
9f975259 zhangq95  2018-05-04  640  	tsk = find_task_by_pid_ns(*start, &init_pid_ns);
9f975259 zhangq95  2018-05-04  641  	getboottime64(&boottime);
9f975259 zhangq95  2018-05-04  642
9f975259 zhangq95  2018-05-04  643  	if (in_noninit_pid_ns(tsk) &&
9f975259 zhangq95  2018-05-04  644  		task_in_nonroot_cpuacct(tsk)) {
9f975259 zhangq95  2018-05-04  645  		if (task_css(tsk, cpuset_cgrp_id)) {
9f975259 zhangq95  2018-05-04  646  			memset(&cpus_allowed, 0, sizeof(cpus_allowed));
9f975259 zhangq95  2018-05-04  647  			get_tsk_cpu_allowed(tsk, &cpus_allowed);
9f975259 zhangq95  2018-05-04  648  		}
9f975259 zhangq95  2018-05-04  649
9f975259 zhangq95  2018-05-04  650  		start_time = tsk->real_start_time / NSEC_PER_SEC;
9f975259 zhangq95  2018-05-04  651  		start_time += (unsigned long long)boottime.tv_sec;
9f975259 zhangq95  2018-05-04  652
9f975259 zhangq95  2018-05-04  653  		for_each_cpu_and(i, cpu_possible_mask, &cpus_allowed) {
9f975259 zhangq95  2018-05-04  654  			switches += task_ca_procs_stat(tsk, i,
9f975259 zhangq95  2018-05-04  655  				CPUACCT_PROCS_SWITCHES, 0);
9f975259 zhangq95  2018-05-04  656  			forks += task_ca_procs_stat(tsk, i,
9f975259 zhangq95  2018-05-04  657  				CPUACCT_PROCS_FORKS, 0);
9f975259 zhangq95  2018-05-04  658  			nr_runnable += task_ca_procs_stat(tsk, i,
9f975259 zhangq95  2018-05-04  659  				CPUACCT_PROCS_RUNNING, 0);
9f975259 zhangq95  2018-05-04  660  			iowait += task_ca_procs_stat(tsk, i,
9f975259 zhangq95  2018-05-04  661  				CPUACCT_PROCS_IOWAIT, 0);
9f975259 zhangq95  2018-05-04  662
9f975259 zhangq95  2018-05-04  663  			for (j = 0; j < NR_SOFTIRQS; j++) {
9f975259 zhangq95  2018-05-04  664  				tmp = task_ca_procs_stat(tsk, i, j, 1);
9f975259 zhangq95  2018-05-04  665  				per_softirq_nums[j] += tmp;
9f975259 zhangq95  2018-05-04  666  				sum_softirq += tmp;
9f975259 zhangq95  2018-05-04  667  			}
9f975259 zhangq95  2018-05-04  668  		}
9f975259 zhangq95  2018-05-04  669
9f975259 zhangq95  2018-05-04  670  	} else {
9f975259 zhangq95  2018-05-04  671  		cpumask_copy(&cpus_allowed, cpu_possible_mask);
9f975259 zhangq95  2018-05-04  672  		nr_runnable = nr_running();
9f975259 zhangq95  2018-05-04  673  		forks = total_forks;
9f975259 zhangq95  2018-05-04  674  		iowait = nr_iowait();
9f975259 zhangq95  2018-05-04  675  		switches = nr_context_switches();
9f975259 zhangq95  2018-05-04  676  		start_time = (unsigned long long)boottime.tv_sec;
9f975259 zhangq95  2018-05-04  677
9f975259 zhangq95  2018-05-04  678  		for (j = 0; j < NR_SOFTIRQS; j++) {
9f975259 zhangq95  2018-05-04  679  			unsigned long softirq_stat = kstat_softirqs_cpu(j, i);
9f975259 zhangq95  2018-05-04  680
9f975259 zhangq95  2018-05-04  681  			per_softirq_nums[j] += softirq_stat;
9f975259 zhangq95  2018-05-04  682  			sum_softirq += softirq_stat;
9f975259 zhangq95  2018-05-04  683  		}
9f975259 zhangq95  2018-05-04  684  	}
9f975259 zhangq95  2018-05-04  685
9f975259 zhangq95  2018-05-04  686  	seq_printf(s, "softirq %lu ", sum_softirq);
9f975259 zhangq95  2018-05-04  687  	for (j = 0; j < NR_SOFTIRQS; j++)
9f975259 zhangq95  2018-05-04  688  		seq_printf(s, "%lu ", per_softirq_nums[j]);
9f975259 zhangq95  2018-05-04  689
9f975259 zhangq95  2018-05-04  690  	seq_puts(s, "\n");
9f975259 zhangq95  2018-05-04  691  	seq_printf(s,
9f975259 zhangq95  2018-05-04  692  		"ctxt %llu\n"
9f975259 zhangq95  2018-05-04  693  		"btime %llu\n"
9f975259 zhangq95  2018-05-04  694  		"processes %lu\n"
9f975259 zhangq95  2018-05-04  695  		"procs_running %lu\n"
9f975259 zhangq95  2018-05-04  696  		"procs_blocked %lu\n",
9f975259 zhangq95  2018-05-04  697  		switches,
9f975259 zhangq95  2018-05-04  698  		start_time,
9f975259 zhangq95  2018-05-04  699  		forks,
9f975259 zhangq95  2018-05-04  700  		nr_runnable,
9f975259 zhangq95  2018-05-04  701  		iowait);
9f975259 zhangq95  2018-05-04  702
9f975259 zhangq95  2018-05-04  703  	mod_delayed_work(cgroup_pidlist_destroy_wq, &l->destroy_dwork,
9f975259 zhangq95  2018-05-04  704  		CGROUP_PIDLIST_DESTROY_DELAY);
9f975259 zhangq95  2018-05-04  705  	mutex_unlock(&cgrp->pidlist_mutex);
9f975259 zhangq95  2018-05-04  706
9f975259 zhangq95  2018-05-04  707  	return 0;
9f975259 zhangq95  2018-05-04  708  }
9f975259 zhangq95  2018-05-04  709

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe cgroups" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux