Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751097AbdGGGjq (ORCPT ); Fri, 7 Jul 2017 02:39:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34055 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbdGGGjp (ORCPT ); Fri, 7 Jul 2017 02:39:45 -0400 Subject: Re: [next-20170609] Oops while running CPU off-on (cpuset.c/cpuset_can_attach) From: Abdul Haleem To: Tejun Heo Cc: sachinp , Stephen Rothwell , ego , linux-kernel , Li Zefan , linuxppc-dev , Ingo Molnar , mpe Date: Fri, 07 Jul 2017 12:09:34 +0530 In-Reply-To: <20170705152855.GD19330@htj.duckdns.org> References: <1497266622.15415.39.camel@abdul.in.ibm.com> <20170627153608.GD2289@htj.duckdns.org> <1499092582.10651.15.camel@abdul.in.ibm.com> <20170705152855.GD19330@htj.duckdns.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17070706-0040-0000-0000-0000034107C8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070706-0041-0000-0000-00000CBC3AE6 Message-Id: <1499409574.19784.26.camel@abdul.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-07_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707070108 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3679 Lines: 134 On Wed, 2017-07-05 at 11:28 -0400, Tejun Heo wrote: > Hello, Abdul. > > Thanks for the debug info. Can you please see whether the following > patch fixes the issue? It is my pleasure and yes the patch fixes the problem. > If the problem is too difficult to reproduce The problem was reproducible all the time. With the patch fix, I tried multiple times and long runs of cpu off-on cycles but no Oops is seen. Thank you for spending your valuable time on fixing this issue. Reported-and-tested-by : Abdul Haleem > to confirm the fix by seeing whether it no longer triggers, please let > me know. We can instead apply a patch which triggers WARN on the > failing condition to confirm the diagnosis. > > Thanks. > > diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h > index 793565c05742..8b4c3c2f2509 100644 > --- a/kernel/cgroup/cgroup-internal.h > +++ b/kernel/cgroup/cgroup-internal.h > @@ -33,6 +33,9 @@ struct cgroup_taskset { > struct list_head src_csets; > struct list_head dst_csets; > > + /* the number of tasks in the set */ > + int nr_tasks; > + > /* the subsys currently being processed */ > int ssid; > > diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c > index dbfd7028b1c6..e3c4152741a3 100644 > --- a/kernel/cgroup/cgroup.c > +++ b/kernel/cgroup/cgroup.c > @@ -1954,6 +1954,8 @@ static void cgroup_migrate_add_task(struct task_struct *task, > if (!cset->mg_src_cgrp) > return; > > + mgctx->tset.nr_tasks++; > + > list_move_tail(&task->cg_list, &cset->mg_tasks); > if (list_empty(&cset->mg_node)) > list_add_tail(&cset->mg_node, > @@ -2047,16 +2049,18 @@ static int cgroup_migrate_execute(struct cgroup_mgctx *mgctx) > return 0; > > /* check that we can legitimately attach to the cgroup */ > - do_each_subsys_mask(ss, ssid, mgctx->ss_mask) { > - if (ss->can_attach) { > - tset->ssid = ssid; > - ret = ss->can_attach(tset); > - if (ret) { > - failed_ssid = ssid; > - goto out_cancel_attach; > + if (tset->nr_tasks) { > + do_each_subsys_mask(ss, ssid, mgctx->ss_mask) { > + if (ss->can_attach) { > + tset->ssid = ssid; > + ret = ss->can_attach(tset); > + if (ret) { > + failed_ssid = ssid; > + goto out_cancel_attach; > + } > } > - } > - } while_each_subsys_mask(); > + } while_each_subsys_mask(); > + } > > /* > * Now that we're guaranteed success, proceed to move all tasks to > @@ -2085,25 +2089,29 @@ static int cgroup_migrate_execute(struct cgroup_mgctx *mgctx) > */ > tset->csets = &tset->dst_csets; > > - do_each_subsys_mask(ss, ssid, mgctx->ss_mask) { > - if (ss->attach) { > - tset->ssid = ssid; > - ss->attach(tset); > - } > - } while_each_subsys_mask(); > + if (tset->nr_tasks) { > + do_each_subsys_mask(ss, ssid, mgctx->ss_mask) { > + if (ss->attach) { > + tset->ssid = ssid; > + ss->attach(tset); > + } > + } while_each_subsys_mask(); > + } > > ret = 0; > goto out_release_tset; > > out_cancel_attach: > - do_each_subsys_mask(ss, ssid, mgctx->ss_mask) { > - if (ssid == failed_ssid) > - break; > - if (ss->cancel_attach) { > - tset->ssid = ssid; > - ss->cancel_attach(tset); > - } > - } while_each_subsys_mask(); > + if (tset->nr_tasks) { > + do_each_subsys_mask(ss, ssid, mgctx->ss_mask) { > + if (ssid == failed_ssid) > + break; > + if (ss->cancel_attach) { > + tset->ssid = ssid; > + ss->cancel_attach(tset); > + } > + } while_each_subsys_mask(); > + } > out_release_tset: > spin_lock_irq(&css_set_lock); > list_splice_init(&tset->dst_csets, &tset->src_csets); > -- Regard's Abdul Haleem IBM Linux Technology Centre