Re: [PATCH] workqueue: combine judgments in the loop ofmaybe_create_worker

2018-09-12 Thread Lai Jiangshan
On Thu, Sep 13, 2018 at 9:51 AM wrote: > > >> From: Liu Song > >> > >> Although the 'need_to_create_worker' has been determined to be > >> true before entering the function. However, adjusting the order > >> of judgment can combine two judgments in the loop. Also improve > >> the matching

Re: Consolidating RCU-bh, RCU-preempt, and RCU-sched

2018-07-12 Thread Lai Jiangshan
On Fri, Jul 13, 2018 at 8:02 AM, Paul E. McKenney wrote: > Hello! > > I now have a semi-reasonable prototype of changes consolidating the > RCU-bh, RCU-preempt, and RCU-sched update-side APIs in my -rcu tree. > There are likely still bugs to be fixed and probably other issues as well, > but a

Re: [PATCH 3/6] workqueue: Make worker_attach/detach_pool() update worker->pool

2018-05-19 Thread Lai Jiangshan
On Thu, May 17, 2018 at 12:34 PM, Tejun Heo wrote: > For historical reasons, the worker attach/detach functions don't > currently manage worker->pool and the callers are manually and > inconsistently updating it. > > This patch moves worker->pool updates into the worker

Re: [PATCH 6/8] RCU, workqueue: Implement rcu_work

2018-03-20 Thread Lai Jiangshan
On Tue, Mar 20, 2018 at 12:45 AM, Tejun Heo <t...@kernel.org> wrote: > Hello, Lai. > > On Fri, Mar 16, 2018 at 02:01:35PM +0800, Lai Jiangshan wrote: >> > +bool flush_rcu_work(struct rcu_work *rwork) >> > +{ >> > + if (test_bit(WORK_STRU

[PATCH] workqueue: remove the comment about the old manager_arb mutex

2018-03-20 Thread Lai Jiangshan
The manager_arb mutex doesn't exist any more. Signed-off-by: Lai Jiangshan <jiangshan...@gmail.com> --- kernel/workqueue.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 19785a092026..698b6f1ecddd 100644 --- a/kernel/workqueue.c +++ b/

[PATCH] workqueue: fix the comments of nr_idle

2018-03-20 Thread Lai Jiangshan
Since the worker rebinding behavior was refactored, there is no idle worker off the idle_list now. The comment is outdated and can be just removed. It also groups nr_workers and nr_idle together. Signed-off-by: Lai Jiangshan <jiangshan...@gmail.com> --- kernel/workqueue.c | 5 ++---

[PATCH] workqueue: make manage_workers() and pool destruction exclusive

2018-03-19 Thread Lai Jiangshan
refcount of the pool in manage_workers(). "indirect" means it gets a refcount of the first involved pwq which holds a refcount of the pool. This refcount can prevent the pool from being destroyed. The original synchronization mechanism (wq_manager_wait) is also removed. Signed-off-by: Lai

Re: [PATCH 6/8] RCU, workqueue: Implement rcu_work

2018-03-16 Thread Lai Jiangshan
n __queue_work() */ > + local_irq_disable(); > + __queue_work(WORK_CPU_UNBOUND, rwork->wq, >work); > + local_irq_enable(); > +} > + > +/** > + * queue_rcu_work - queue work after a RCU grace period > + * @wq: workqueue to use > + * @rwork: work to queue

[tip:smp/hotplug] cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states

2018-03-14 Thread tip-bot for Lai Jiangshan
Commit-ID: 17a2f1ced0280068897990b0dd25ce70555b8ac7 Gitweb: https://git.kernel.org/tip/17a2f1ced0280068897990b0dd25ce70555b8ac7 Author: Lai Jiangshan <jiangshan...@gmail.com> AuthorDate: Fri, 1 Dec 2017 21:50:05 +0800 Committer: Thomas Gleixner <t...@linutronix.de> CommitD

Re: Simplifying our RCU models

2018-03-09 Thread Lai Jiangshan
On Tue, Mar 6, 2018 at 12:14 AM, Paul E. McKenney wrote: > On Mon, Mar 05, 2018 at 08:33:20AM -0600, Eric W. Biederman wrote: >> >> Moving this discussion to a public list as discussing how to reduce the >> number of rcu variants does not make sense in private. We

Re: [PATCH 7/7] RCU, workqueue: Implement rcu_work

2018-03-07 Thread Lai Jiangshan
On Wed, Mar 7, 2018 at 10:54 PM, Paul E. McKenney <paul...@linux.vnet.ibm.com> wrote: > On Wed, Mar 07, 2018 at 10:49:49AM +0800, Lai Jiangshan wrote: >> On Wed, Mar 7, 2018 at 1:33 AM, Tejun Heo <t...@kernel.org> wrote: >> >> > +/** >> > + * queue_r

Re: [PATCH 7/7] RCU, workqueue: Implement rcu_work

2018-03-06 Thread Lai Jiangshan
On Wed, Mar 7, 2018 at 1:33 AM, Tejun Heo wrote: > +/** > + * queue_rcu_work_on - queue work on specific CPU after a RCU grace period > + * @cpu: CPU number to execute work on > + * @wq: workqueue to use > + * @rwork: work to queue For many people, "RCU grace period" is clear

Re: [PATCH RFC 01/16] prcu: Add PRCU implementation

2018-01-29 Thread Lai Jiangshan
On Tue, Jan 23, 2018 at 3:59 PM, wrote: > From: Heng Zhang > > This RCU implementation (PRCU) is based on a fast consensus protocol > published in the following paper: > > Fast Consensus Using Bounded Staleness for Scalable Read-mostly >

Re: [RFC PATCH V5 5/5] workqueue: introduce a way to set workqueue's scheduler

2018-01-28 Thread Lai Jiangshan
On Mon, Jan 29, 2018 at 12:41 PM, Mike Galbraith <efa...@gmx.de> wrote: > On Mon, 2018-01-29 at 12:15 +0800, Lai Jiangshan wrote: >> I think adding priority boost to workqueue(flush_work()) is the best >> way to fix the problem. > > I disagree, priority boosting is

Re: [RFC PATCH V5 5/5] workqueue: introduce a way to set workqueue's scheduler

2018-01-28 Thread Lai Jiangshan
policy=1 prio=1 nice=0 > # cat /sys/devices/virtual/workqueue/system_percpu_highpri/sched_attr > policy=0 prio=0 nice=-20 > # echo "policy=1 prio=2 nice=0" > > /sys/devices/virtual/workqueue/system_percpu_highpri/s

Re: [PATCH] workqueue: Handle race between wake up and rebind

2018-01-17 Thread Lai Jiangshan
On Wed, Jan 17, 2018 at 4:08 AM, Neeraj Upadhyay wrote: > > > On 01/16/2018 11:05 PM, Tejun Heo wrote: >> >> Hello, Neeraj. >> >> On Mon, Jan 15, 2018 at 02:08:12PM +0530, Neeraj Upadhyay wrote: >>> >>> - kworker/0:0 gets chance to run on cpu1; while processing >>>a

Re: [PATCH] cpu/hotplug: merge cpuhp_bp_states_ap_states as cpuhp_hp_states

2017-12-03 Thread Lai Jiangshan
On Sun, Dec 3, 2017 at 2:33 PM, Paul E. McKenney <paul...@linux.vnet.ibm.com> wrote: > On Fri, Dec 01, 2017 at 09:50:05PM +0800, Lai Jiangshan wrote: >> cpuhp_bp_states_ap_states have diffent set of steps >> without any conflicting configed steps, so that they can >> be

Re: [PATCH tip/core/rcu 2/6] srcu: Change printk() %p to %pK

2017-12-01 Thread Lai Jiangshan
but it doesn't hurt to > change it and doing so avoids script-generated noise. > > Reported-by: Tobin C. Harding <m...@tobin.cc> > Signed-off-by: Paul E. McKenney <paul...@linux.vnet.ibm.com> Reviewed-by: Lai Jiangshan <jiangshan...@gmail.com> > --- > kernel/r

Re: [PATCH tip/core/rcu 05/10] workqueue: Eliminate cond_resched_rcu_qs() in favor of cond_resched()

2017-12-01 Thread Lai Jiangshan
aul E. McKenney <paul...@linux.vnet.ibm.com> > Cc: Tejun Heo <t...@kernel.org> > Cc: Lai Jiangshan <jiangshan...@gmail.com> Reviewed-by: Lai Jiangshan <jiangshan...@gmail.com> > --- > kernel/workqueue.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion

[PATCH] workqueue/hotplug: remove the workaround in rebind_workers()

2017-12-01 Thread Lai Jiangshan
Sine the cpu/hotplug refactor is done, the hotplug callbacks are called properly. So the workaround is useless. Signed-off-by: Lai Jiangshan <jiangshan...@gmail.com> --- kernel/workqueue.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workq

[PATCH] workqueue/hotplug: simplify workqueue_offline_cpu()

2017-12-01 Thread Lai Jiangshan
Since the refactor for the cpu/hotplug is done, workqueue_offline_cpu() is ensured to be run on the local cpu which is going off. Signed-off-by: Lai Jiangshan <jiangshan...@gmail.com> --- kernel/workqueue.c | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff

[PATCH] cpu/hotplug: merge cpuhp_bp_states_ap_states as cpuhp_hp_states

2017-12-01 Thread Lai Jiangshan
cpuhp_bp_states_ap_states have diffent set of steps without any conflicting configed steps, so that they can be merged. The original `[CPUHP_BRINGUP_CPU] = { },` is removed, because the new cpuhp_hp_states has CPUHP_ONLINE index which is larger than CPUHP_BRINGUP_CPU. Signed-off-by: Lai

Re: [PATCH 6/7] smp/hotplug: Differentiate the AP-work lockdep class between up and down

2017-11-30 Thread Lai Jiangshan
On Thu, Sep 21, 2017 at 1:00 AM, Peter Zijlstra wrote: > With lockdep-crossrelease we get deadlock reports that span cpu-up and > cpu-down chains. Such deadlocks cannot possibly happen because cpu-up > and cpu-down are globally serialized. > > CPU0 CPU1

[tip:smp/urgent] smp/hotplug: Move step CPUHP_AP_SMPCFD_DYING to the correct place

2017-11-28 Thread tip-bot for Lai Jiangshan
Commit-ID: 46febd37f9c758b05cd25feae8512f22584742fe Gitweb: https://git.kernel.org/tip/46febd37f9c758b05cd25feae8512f22584742fe Author: Lai Jiangshan <jiangshan...@gmail.com> AuthorDate: Tue, 28 Nov 2017 21:19:53 +0800 Committer: Thomas Gleixner <t...@linutronix.de> CommitD

[PATCH] smp/hotplug: move step CPUHP_AP_SMPCFD_DYING to the correct place

2017-11-28 Thread Lai Jiangshan
ot;smpcfd:dying" was missing before. So was the invocation of the function smpcfd_dying_cpu(). Signed-off-by: Lai Jiangshan <jiangshan...@gmail.com> CC: Richard Weinberger <rich...@nod.at> cc: sta...@vger.kernel.org (v4.7+) --- kernel/cpu.c | 10 +- 1 file changed, 5 insertion

Re: [PATCH v2] workqueue: Fix NULL pointer dereference

2017-10-29 Thread Lai Jiangshan
> |-current->current_pwq is NULL here! > |-schedule() > > > Avoid it by checking for task context in current_wq_worker(), and > if not in task context, we shouldn't use the 'current' to check the > condition. > > Re

Re: [PATCH] workqueue: Fix NULL pointer dereference

2017-10-26 Thread Lai Jiangshan
On Tue, Oct 24, 2017 at 9:18 AM, Li Bin wrote: > When queue_work() is used in irq handler, there is a potential > case that trigger NULL pointer dereference. > > worker_thread() > |-spin_lock_irq() >

Re: [PATCH v2 workqueue/for-4.14-fixes] workqueue: replace pool->manager_arb mutex with a flag

2017-10-10 Thread Lai Jiangshan
truction as > suggested by Boqun. > > Signed-off-by: Tejun Heo <t...@kernel.org> > Reported-by: Josef Bacik <jo...@toxicpanda.com> > Cc: Peter Zijlstra <pet...@infradead.org> > Cc: Boqun Feng <boqun.f...@gmail.com> > Cc: sta...@vger.kernel.org > --- > kerne

Re: [PATCH workqueue/for-4.14-fixes] workqueue: replace pool->manager_arb mutex with a flag

2017-10-09 Thread Lai Jiangshan
On Mon, Oct 9, 2017 at 11:08 PM, Tejun Heo <t...@kernel.org> wrote: > Hello, > > On Mon, Oct 09, 2017 at 11:02:34PM +0800, Lai Jiangshan wrote: >> I was also thinking alternative code when reviewing. >> The first is quite obvious. Testing POOL_MANAGER_ACTIVE >>

Re: [PATCH workqueue/for-4.14-fixes] workqueue: replace pool->manager_arb mutex with a flag

2017-10-09 Thread Lai Jiangshan
On Mon, Oct 9, 2017 at 9:21 PM, Tejun Heo wrote: > Josef reported a HARDIRQ-safe -> HARDIRQ-unsafe lock order detected by > lockdep: > > [ 1270.472259] WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected > [ 1270.472783] 4.14.0-rc1-xfstests-12888-g76833e8 #110 Not

Re: [RFC] workqueue: Fix irq inversion deadlock in manage_workers()

2017-10-09 Thread Lai Jiangshan
On Sun, Oct 8, 2017 at 5:02 PM, Boqun Feng wrote: > Josef reported a HARDIRQ-safe -> HARDIRQ-unsafe lock order detected by > lockdep: > > | [ 1270.472259] WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected > | [ 1270.472783] 4.14.0-rc1-xfstests-12888-g76833e8 #110

Re: KVM PV (was: Re: [PATCH v2 2/2] x86/lguest: remove lguest support)

2017-09-29 Thread Lai Jiangshan
On Sat, Sep 30, 2017 at 12:39 AM, Paolo Bonzini <pbonz...@redhat.com> wrote: > On 29/09/2017 17:47, Lai Jiangshan wrote: >> Hello, all >> >> An interesting (at least to me) thinking came up to me when I found >> that the lguest was removed. But I don't hav

KVM PV (was: Re: [PATCH v2 2/2] x86/lguest: remove lguest support)

2017-09-29 Thread Lai Jiangshan
Hello, all An interesting (at least to me) thinking came up to me when I found that the lguest was removed. But I don't have enough knowledge to find out the answer nor energy to implement it in some time. Is it possible to implement kvm-pv which allows kvm to run on the boxes without hardware

Re: single-threaded wq lockdep is broken

2017-06-02 Thread Lai Jiangshan
On Wed, May 31, 2017 at 4:36 PM, Johannes Berg wrote: > Hi, > >> > #include >> > #include >> > #include >> > #include >> > #include >> > >> > DEFINE_MUTEX(mtx); >> > static struct workqueue_struct *wq; >> > static struct work_struct w1, w2; >> > >> > static void

Re: single-threaded wq lockdep is broken

2017-05-31 Thread Lai Jiangshan
On Mon, May 29, 2017 at 3:33 AM, Johannes Berg wrote: > Hi Tejun, > > I suspect this is a long-standing bug introduced by all the pool rework > you did at some point, but I don't really know nor can I figure out how > to fix it right now. I guess it could possibly also

Re: [PATCH v4 07/15] lockdep: Implement crossrelease feature

2017-01-12 Thread Lai Jiangshan
> + > +/* > + * No contention. Irq disable is only required. > + */ > +static int same_context_plock(struct pend_lock *plock) > +{ > + struct task_struct *curr = current; > + int cpu = smp_processor_id(); > + > + /* In the case of hardirq context */ > + if

Re: [PATCH RFC tip/core/rcu] SRCU rewrite

2016-11-17 Thread Lai Jiangshan
On Tue, Nov 15, 2016 at 10:37 PM, Paul E. McKenney wrote: > On Tue, Nov 15, 2016 at 09:44:45AM +0800, Boqun Feng wrote: >> >> __srcu_read_lock() used to be called with preemption disabled. I guess >> the reason was because we have two percpu variables to increase. So

Re: [PATCH RFC tip/core/rcu] SRCU rewrite

2016-11-17 Thread Lai Jiangshan
On Thu, Nov 17, 2016 at 10:45 PM, Boqun Feng <boqun.f...@gmail.com> wrote: > On Thu, Nov 17, 2016 at 06:38:29AM -0800, Paul E. McKenney wrote: >> On Thu, Nov 17, 2016 at 05:49:57AM -0800, Paul E. McKenney wrote: >> > On Thu, Nov 17, 2016 at 08:18:51PM +0800, Lai Jiangshan w

Re: [PATCH RFC tip/core/rcu] SRCU rewrite

2016-11-17 Thread Lai Jiangshan
eted) & 0x1; > - __this_cpu_inc(sp->per_cpu_ref->c[idx]); > + __this_cpu_inc(sp->per_cpu_ref->lock_count[idx]); > smp_mb(); /* B */ /* Avoid leaking the critical section. */ > - __this_cpu_inc(sp->per_cpu_ref->seq[idx]); > return idx; > } > EXPORT_SYMBOL_GPL(__srcu_read_lock); > @@ -314,7 +285,7 @@ EXPORT_SYMBOL_GPL(__srcu_read_lock); > void __srcu_read_unlock(struct srcu_struct *sp, int idx) > { > smp_mb(); /* C */ /* Avoid leaking the critical section. */ > - this_cpu_dec(sp->per_cpu_ref->c[idx]); > + this_cpu_inc(sp->per_cpu_ref->unlock_count[idx]); > } > EXPORT_SYMBOL_GPL(__srcu_read_unlock); > > @@ -349,7 +320,7 @@ static bool try_check_zero(struct srcu_struct *sp, int > idx, int trycount) > > /* > * Increment the ->completed counter so that future SRCU readers will > - * use the other rank of the ->c[] and ->seq[] arrays. This allows > + * use the other rank of the ->(un)lock_count[] arrays. This allows > * us to wait for pre-existing readers in a starvation-free manner. > */ > static void srcu_flip(struct srcu_struct *sp) > Acked-by: Lai Jiangshan <jiangshan...@gmail.com>

Re: [PATCH RFC tip/core/rcu] SRCU rewrite

2016-11-17 Thread Lai Jiangshan
On Thu, Nov 17, 2016 at 10:31 PM, Boqun Feng <boqun.f...@gmail.com> wrote: > On Thu, Nov 17, 2016 at 08:18:51PM +0800, Lai Jiangshan wrote: >> On Tue, Nov 15, 2016 at 10:37 PM, Paul E. McKenney >> <paul...@linux.vnet.ibm.com> wrote: >> > On Tue, Nov 15, 2016 a

Re: [PATCH] Fix: disable sys_membarrier when nohz_full is enabled

2016-11-16 Thread Lai Jiangshan
u.desnoy...@efficios.com> > CC: "Paul E. McKenney" <paul...@linux.vnet.ibm.com> > CC: Josh Triplett <j...@joshtriplett.org> > CC: Steven Rostedt <rost...@goodmis.org> > CC: Lai Jiangshan <jiangshan...@gmail.com> > CC: <sta...@vger.kernel.org

Re: [Linux v4.2] workqueue: llvmlinux: acpid: BUG: sleeping function called from invalid context at kernel/workqueue.c:2680

2015-09-09 Thread Lai Jiangshan
Hi, TJ I think we need to add might_sleep() on the top of __cancel_work_timer(). The might_sleep() on the start_flush_work() doesn't cover all the paths of __cancel_work_timer(). And it can help to narrow the area of this bug. Hi Sedat Dilek [ 24.705704] irq event stamp: 19968 [ 24.705706]

Re: [Ksummit-discuss] [BELATED CORE TOPIC] context tracking / nohz / RCU state

2015-08-12 Thread Lai Jiangshan
On Thu, Aug 13, 2015 at 12:03 AM, Paul E. McKenney paul...@linux.vnet.ibm.com wrote: On Wed, Aug 12, 2015 at 04:27:34PM +0200, Frederic Weisbecker wrote: On Tue, Aug 11, 2015 at 08:42:58PM +0200, Luis R. Rodriguez wrote: On Tue, Aug 11, 2015 at 10:49:36AM -0700, Andy Lutomirski wrote: This

Re: [Ksummit-discuss] [BELATED CORE TOPIC] context tracking / nohz / RCU state

2015-08-11 Thread Lai Jiangshan
On Wed, Aug 12, 2015 at 1:49 AM, Andy Lutomirski l...@amacapital.net wrote: This is a bit late, but here goes anyway. Having played with the x86 context tracking hooks for awhile, I think it would be nice if core code that needs to be aware of CPU context (kernel, user, idle, guest, etc)

Re: [Ksummit-discuss] [CORE TOPIC] lightweight per-cpu locks / restartable sequences

2015-07-22 Thread Lai Jiangshan
On Mon, Jul 13, 2015 at 5:57 PM, Peter Zijlstra pet...@infradead.org wrote: On Fri, Jul 10, 2015 at 12:26:21PM -0500, Christoph Lameter wrote: On Thu, 9 Jul 2015, Chris Mason wrote: I think the topic is really interesting and we'll be able to get numbers from production workloads to help

Re: [Ksummit-discuss] [CORE TOPIC] lightweight per-cpu locks / restartable sequences

2015-07-22 Thread Lai Jiangshan
On Fri, Jul 10, 2015 at 3:09 AM, Chris Mason c...@fb.com wrote: We've started experimenting with these to cut overheads in a few critical places, and while we don't have numbers yet I really hope it won't take too long. I think the topic is really interesting and we'll be able to get

Re: [Ksummit-discuss] [CORE TOPIC] lightweight per-cpu locks / restartable sequences

2015-07-22 Thread Lai Jiangshan
On Mon, Jul 13, 2015 at 5:57 PM, Peter Zijlstra pet...@infradead.org wrote: On Fri, Jul 10, 2015 at 12:26:21PM -0500, Christoph Lameter wrote: On Thu, 9 Jul 2015, Chris Mason wrote: I think the topic is really interesting and we'll be able to get numbers from production workloads to help

[PATCH] rcu: update MAINTAINERS entry

2015-07-01 Thread Lai Jiangshan
Update my email address. The old la...@cn.fujitsu.com will ended after Jul 10 2015. Signed-off-by: Lai Jiangshan jiangshan...@gmail.com Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- MAINTAINERS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b

[PATCH] workqueue: add myself as a dedicated reviwer

2015-07-01 Thread Lai Jiangshan
I am one of the dedicated reviwers of workqueue.c. Now I add myself to the MAINTAINERS entry with the updated email address. The old la...@cn.fujitsu.com will be ended soon. Signed-off-by: Lai Jiangshan jiangshan...@gmail.com Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- MAINTAINERS | 1

Re: [RFC] kthread_create_on_node is failing to honor the node choice

2015-06-25 Thread Lai Jiangshan
...@linux.vnet.ibm.com Cc: Tejun Heo t...@kernel.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mel Gorman mgor...@suse.de Cc: linux-kernel@vger.kernel.org --- kernel/kthread.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index

[PATCH 3/4] workqueue: reuse the current default pwq when its attrs unchanged

2015-06-03 Thread Lai Jiangshan
this change, ctx-dfl_pwq-refcnt++ could be dangerous when ctx-dfl_pwq is a reusing pwq which may be receiving work items or processing work items and hurts concurrency [get|put]_pwq(), so we use get_pwq_unlocked() instead. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 16

[PATCH 0/4 V3] workqueue: avoid creating identical pwqs

2015-06-03 Thread Lai Jiangshan
not replement it in future Cc: Tejun Heo t...@kernel.org Lai Jiangshan (4): workqueue: introduce get_pwq_unlocked() workqueue: reuse the current per-node pwq when its attrs are unchanged workqueue: reuse the current default pwq when its attrs unchanged workqueue: reuse

[PATCH 2/4] workqueue: reuse the current per-node pwq when its attrs are unchanged

2015-06-03 Thread Lai Jiangshan
already made the current pwq be reused when its attrs are unaffected, but we move the code of fetching current pwq closer to the code of testing. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff

[PATCH 1/4] workqueue: introduce get_pwq_unlocked()

2015-06-03 Thread Lai Jiangshan
-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 31 --- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index afe7c53..6aa9bd5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1065,6 +1065,20

[PATCH 4/4] workqueue: reuse wq_update_unbound_numa_attrs_buf as temporary attrs

2015-06-03 Thread Lai Jiangshan
(). The comment for using wq_calc_node_attrs_buf in wq_update_unbound_numa() is also moved to the defination of the wq_calc_node_attrs_buf. This change also avoids frequently alloc/free the tmp_attrs for every workqueue when the low level cpumask is being updated. Signed-off-by: Lai Jiangshan la

Re: [PATCH 4/7 V2] workqueue: reuse the current per-node pwq when its attrs unchanged

2015-05-25 Thread Lai Jiangshan
Hi, TJ The patch 4/5/6 does reduce cpu and temporary-memory usage sometimes. But it is in slow path where small optimization is commonly unwelcome at. Do I need to refactor the patches? I'm in doubt for the necessary. Thanks, Lai -- To unsubscribe from this list: send the line unsubscribe

[PATCH 0/3] workqueue: misc cleanup

2015-05-20 Thread Lai Jiangshan
patch12 are simple cleaups and reflect to recently changes. patch3 just moves code. Cc: Tejun Heo t...@kernel.org Lai Jiangshan (3): workqueue: remove the declaration of copy_workqueue_attrs() workqueue: remove the lock from wq_sysfs_prep_attrs() workqueue: move flush_scheduled_work

[PATCH 2/3] workqueue: remove the lock from wq_sysfs_prep_attrs()

2015-05-20 Thread Lai Jiangshan
Reading to wq-unbound_attrs requires protection of either wq_pool_mutex or wq-mutex, and wq_sysfs_prep_attrs() is called with wq_pool_mutex held, so we don't need to grab wq-mutex here. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 4 ++-- 1 file changed, 2

[PATCH 3/3] workqueue: move flush_scheduled_work() to workqueue.h

2015-05-20 Thread Lai Jiangshan
flush_scheduled_work() is just a simple call to flush_work(). Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- include/linux/workqueue.h | 30 +- kernel/workqueue.c| 30 -- 2 files changed, 29 insertions(+), 31 deletions

[PATCH 1/3] workqueue: remove the declaration of copy_workqueue_attrs()

2015-05-20 Thread Lai Jiangshan
This pre-declaration was unneeded since a previous refactor patch 6ba94429c8e7 (workqueue: Reorder sysfs code). Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ee5bf95

[PATCH 1/2] workqueue: separate out and refactor the locking of applying attrs

2015-05-19 Thread Lai Jiangshan
(). The apply_wqattrs_[un]lock() will be also used on later patch for ensuring attrs changes are properly synchronized. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 82 -- 1 file changed, 49 insertions(+), 33 deletions

[PATCH 2/2] workqueue: ensure attrs changes are properly synchronized

2015-05-19 Thread Lai Jiangshan
() | It results that the Process B's operation is totally reverted without any notification, it is a buggy behavior. So this patch moves wq_sysfs_prep_attrs() into the protection under wq_pool_mutex to ensure attrs changes are properly synchronized. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com

[PATCH 0/2 V2] workqueue: refactor and extend the lock for attrs changes

2015-05-19 Thread Lai Jiangshan
Current modification to attrs via sysfs is not fully synchronized. So this patch separates out and refactors the locking and ensures attrs changes are properly synchronized. changed from v1 just split the patch Cc: Tejun Heo t...@kernel.org Lai Jiangshan (2): workqueue: separate out

Re: [PATCH 0/7 V2] workqueue: cleanup for attr management

2015-05-17 Thread Lai Jiangshan
On 05/18/2015 09:26 AM, Tejun Heo wrote: On Mon, May 18, 2015 at 08:39:21AM +0800, Lai Jiangshan wrote: ping Does this reflect the comments from the previous review cycle? This is the V2 version of the V1 pathset. But it is just the updated version of the patch12 of the V1 patchset

Re: [PATCH 0/7 V2] workqueue: cleanup for attr management

2015-05-17 Thread Lai Jiangshan
ping On 05/12/2015 08:32 PM, Lai Jiangshan wrote: Hi, This is the V2 version of the V1 pathset. But it is just the updated version of the patch12 of the V1 patchset. [1/5 V1] is split into [1/7 V2] and [2/7 V2]. [2/5 V1] is split into [3,4,5,6,7/7 V2]. [1/7] extends the wq_pool_mutex

Re: [PATCH 4/5] workqueue: don't expose workqueue_attrs to users

2015-05-12 Thread Lai Jiangshan
On 05/12/2015 09:22 PM, Tejun Heo wrote: Hello, Lai. On Tue, May 12, 2015 at 10:15:28AM +0800, Lai Jiangshan wrote: I'm not sure about this. Yeah, sure, it's a bit more lines of code but at the same time this'd allow us to make the public interface atomic too. What we prolly should do

[PATCH 0/7 V2] workqueue: cleanup for attr management

2015-05-12 Thread Lai Jiangshan
as TJ's suguested. Thanks, Lai Cc: Tejun Heo t...@kernel.org Lai Jiangshan (7): workqueue: wq_pool_mutex protects the attrs-installation workqueue: simplify wq_update_unbound_numa() workqueue: introduce get_pwq_unlocked() workqueue: reuse the current per-node pwq when its attrs unchanged

[PATCH 2/7 V2] workqueue: simplify wq_update_unbound_numa()

2015-05-12 Thread Lai Jiangshan
. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 20 +--- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f02b8ad..c8b9de0 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3708,7

[PATCH 1/7 V2] workqueue: wq_pool_mutex protects the attrs-installation

2015-05-12 Thread Lai Jiangshan
a preparation patch for next several patches which read wq-unbound_attrs, wq-numa_pwq_tbl[] and wq-dfl_pwq with only wq_pool_mutex held. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 27 --- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git

[PATCH 3/7 V2] workqueue: introduce get_pwq_unlocked()

2015-05-12 Thread Lai Jiangshan
-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 33 ++--- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c8b9de0..0fa352d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1067,6

[PATCH 6/7 V2] workqueue: reuse wq_update_unbound_numa_attrs_buf as temporary attrs

2015-05-12 Thread Lai Jiangshan
tmp_attrs is just temporary attrs, we can use wq_update_unbound_numa_attrs_buf for it like wq_update_unbound_numa(); This change also avoids frequently alloc/free the tmp_attrs when the low level cpumask is being updated. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c

[PATCH 5/7 V2] workqueue: reuse the current default pwq when its attrs unchanged

2015-05-12 Thread Lai Jiangshan
this change, ctx-dfl_pwq-refcnt++ could be dangerous when ctx-dfl_pwq is being reused, so we use get_pwq_unlocked() instead. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/workqueue.c b

[PATCH 4/7 V2] workqueue: reuse the current per-node pwq when its attrs unchanged

2015-05-12 Thread Lai Jiangshan
If the cpuamsk is changed, it is possible that only a part of the per-node pwq is affected. This can happen when the user changes the cpumask of a workqueue or the low level cpumask. So we try to reuse the current per-node pwq when its attrs unchanged. Signed-off-by: Lai Jiangshan la

[PATCH 7/7 V2] workqueue: add get_node_unbound_pwq()

2015-05-12 Thread Lai Jiangshan
is reused. Comparing to the old behavior, wq_update_unbound_numa() introduces 3 pairs of lock()/unlock() operations and overhead when the pwq is unchanged. Although cpu-hotplug is cold path, but this case is likely true in the cpu-hotplug path. Signed-off-by: Lai

[PATCH 0/5] workqueue: cleanup for apply_workqueue_attrs()

2015-05-11 Thread Lai Jiangshan
...@kernel.org Lai Jiangshan (5): workqueue: wq_pool_mutex protects the attrs-installation workqueue: merge the similar code workqueue: ensure attrs-changing be sequentially workqueue: don't expose workqueue_attrs to users workqueue: remove no_numa from workqueue_attrs include/linux/workqueue.h

[PATCH 5/5] workqueue: remove no_numa from workqueue_attrs

2015-05-11 Thread Lai Jiangshan
affinity is stored at wq-numa instead. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 44 ++-- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index b08df98..42721a2 100644

[PATCH 2/5] workqueue: merge the similar code

2015-05-11 Thread Lai Jiangshan
(). Changed behavior: 1) Always try to reuse the old pwq. (In old code, apply_workqueue_attrs() doesn't resue the old pwq. 2) Any reusage of old pwq will introduce get_pwq()/put_pwq() and corresponding lock overhead. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com

[PATCH 1/5] workqueue: wq_pool_mutex protects the attrs-installation

2015-05-11 Thread Lai Jiangshan
is in apply_workqueue_attrs(), so this patch touches code less than comments. It is also a preparation patch of merging similar code in apply_workqueue_attrs() and wq_update_unbound_numa() together. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 44

[PATCH 4/5] workqueue: don't expose workqueue_attrs to users

2015-05-11 Thread Lai Jiangshan
with the protection of apply_wqattrs_lock(); This patch is also a preparation patch of next patch which remove no_numa out from the structure workqueue_attrs which requires apply_workqueue_attrs() has an argument to pass numa affinity. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- include/linux

[PATCH 3/5] workqueue: ensure attrs-changing be sequentially

2015-05-11 Thread Lai Jiangshan
wq_pool_mutex to ensure attrs-changing be sequentially. This patch is also a preparation patch for next patch which change the API of apply_workqueue_attrs(). Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- kernel/workqueue.c | 110 + 1 file

Re: [PATCH 3/5] workqueue: ensure attrs-changing be sequentially

2015-05-11 Thread Lai Jiangshan
On 05/11/2015 10:55 PM, Tejun Heo wrote: Hey, Prolly a better subject is ensure attrs changes are properly synchronized On Mon, May 11, 2015 at 05:35:50PM +0800, Lai Jiangshan wrote: Current modification to attrs via sysfs is not atomically

Re: [PATCH 4/5] workqueue: don't expose workqueue_attrs to users

2015-05-11 Thread Lai Jiangshan
On 05/11/2015 10:59 PM, Tejun Heo wrote: On Mon, May 11, 2015 at 05:35:51PM +0800, Lai Jiangshan wrote: workqueue_attrs is an internal-like structure and is exposed with apply_workqueue_attrs() whose user has to investigate the structure before use. And the apply_workqueue_attrs() API

Re: [PATCH 2/5] workqueue: merge the similar code

2015-05-11 Thread Lai Jiangshan
On 05/11/2015 10:31 PM, Tejun Heo wrote: Hello, Lai. Hello, TJ * @node: the target NUMA node - * @cpu_going_down: if = 0, the CPU to consider as offline - * @cpumask: outarg, the resulting cpumask + * @cpu_off: if = 0, the CPU to consider as offline @cpu_off sounds like offset into

[PATCH V9] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-30 Thread Lai Jiangshan
the comment of workqueue_set_unbound_cpumask(); Cc: Christoph Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul...@linux.vnet.ibm.com Cc: Tejun Heo t...@kernel.org Cc: Viresh Kumar

Re: [PATCH 3/3 V8] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-30 Thread Lai Jiangshan
On 04/28/2015 06:16 PM, Lai Jiangshan wrote: On 04/28/2015 11:49 AM, Tejun Heo wrote: Hello, On Tue, Apr 28, 2015 at 10:24:31AM +0800, Lai Jiangshan wrote: Wouldn't this make a lot more sense above when copying @attrs into @new_attrs? The comment there even says make a copy of @attrs

Re: [PATCH 3/3 V8] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-28 Thread Lai Jiangshan
On 04/28/2015 11:49 AM, Tejun Heo wrote: Hello, On Tue, Apr 28, 2015 at 10:24:31AM +0800, Lai Jiangshan wrote: Wouldn't this make a lot more sense above when copying @attrs into @new_attrs? The comment there even says make a copy of @attrs and sanitize it. Copy to @new_attrs, mask

Re: [PATCH 3/3 V8] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-28 Thread Lai Jiangshan
On 04/28/2015 12:36 PM, Mike Galbraith wrote: On Mon, 2015-04-27 at 23:44 -0400, Tejun Heo wrote: So, we need an API to modify the wq_unbound_cpumask, and I provided this public function. Otherwise, the other code can't modify it. I see. I don't have too strong an opinion; however,

[PATCH 0/3 V8] workqueue: Introduce low-level unbound wq sysfs cpumask

2015-04-27 Thread Lai Jiangshan
to calculate the per-nodes' attrs and avoid introducing any branch or special handling. Frederic Weisbecker (1): workqueue: Create low-level unbound workqueues cpumask Lai Jiangshan (2): workqueue: split apply_workqueue_attrs() into 3 stages workqueue: Allow modifying low level unbound workqueue

[PATCH 1/3 V8] workqueue: split apply_workqueue_attrs() into 3 stages

2015-04-27 Thread Lai Jiangshan
into wq_pool_mutex. this is needed to avoid to do the further splitting. Suggested-by: Tejun Heo t...@kernel.org Cc: Christoph Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul

[PATCH 3/3 V8] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-27 Thread Lai Jiangshan
Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul...@linux.vnet.ibm.com Cc: Tejun Heo t...@kernel.org Cc: Viresh Kumar viresh.ku...@linaro.org Cc: Frederic Weisbecker fweis...@gmail.com

[PATCH 2/3 V8] workqueue: Create low-level unbound workqueues cpumask

2015-04-27 Thread Lai Jiangshan
to cpu_possible_mask. Cc: Christoph Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul...@linux.vnet.ibm.com Cc: Tejun Heo t...@kernel.org Cc: Viresh Kumar viresh.ku...@linaro.org Signed-off

Re: [PATCH 3/3 V8] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-27 Thread Lai Jiangshan
Hello --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -424,6 +424,7 @@ struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask); void free_workqueue_attrs(struct workqueue_attrs *attrs); int apply_workqueue_attrs(struct workqueue_struct *wq,

Re: [PATCH 3/3 V8] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-27 Thread Lai Jiangshan
On 04/28/2015 09:44 AM, Lai Jiangshan wrote: + /* save the user configured attrs */ + cpumask_and(new_attrs-cpumask, attrs-cpumask, cpu_possible_mask); Wouldn't this make a lot more sense above when copying @attrs into @new_attrs? The comment there even says make a copy of @attrs

Re: [PATCH 1/3 V7] workqueue: split apply_workqueue_attrs() into 3 stages

2015-04-19 Thread Lai Jiangshan
On 04/17/2015 10:57 PM, Tejun Heo wrote: On Tue, Apr 07, 2015 at 07:26:35PM +0800, Lai Jiangshan wrote: Current apply_workqueue_attrs() includes pwqs-allocation and pwqs-installation, so when we batch multiple apply_workqueue_attrs()s as a transaction, we can't ensure the transaction must

Re: [PATCH v4 6/9] rbtree: Implement generic latch_tree

2015-04-09 Thread Lai Jiangshan
On 04/09/2015 04:14 PM, Peter Zijlstra wrote: On Thu, Apr 09, 2015 at 04:09:07PM +0800, Lai Jiangshan wrote: On 04/09/2015 12:48 AM, Peter Zijlstra wrote: + +struct latch_tree_node { + /* +* Because we have an array of two entries in struct latch_tree_nodes +* it's not possible

Re: [PATCH v4 6/9] rbtree: Implement generic latch_tree

2015-04-09 Thread Lai Jiangshan
On 04/09/2015 12:48 AM, Peter Zijlstra wrote: + +struct latch_tree_node { + /* + * Because we have an array of two entries in struct latch_tree_nodes + * it's not possible to use container_of() to get back to the + * encapsulating structure; therefore we have to put in a

Re: [PATCH v4 1/9] module: Sanitize RCU usage and locking

2015-04-08 Thread Lai Jiangshan
On 04/09/2015 12:48 AM, Peter Zijlstra wrote: +static void module_assert_mutex_or_preempt(void) +{ +#ifdef CONFIG_LOCKDEP + int rcu_held = rcu_read_lock_sched_held(); + int mutex_held = 1; + + if (debug_locks) + mutex_held = lockdep_is_held(module_mutex); + +

[PATCH 2/3 V7] workqueue: Create low-level unbound workqueues cpumask

2015-04-07 Thread Lai Jiangshan
to cpu_possible_mask. Cc: Christoph Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul...@linux.vnet.ibm.com Cc: Tejun Heo t...@kernel.org Cc: Viresh Kumar viresh.ku...@linaro.org Signed-off

[PATCH 3/3 V7] workqueue: Allow modifying low level unbound workqueue cpumask

2015-04-07 Thread Lai Jiangshan
needed. Cc: Christoph Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul...@linux.vnet.ibm.com Cc: Tejun Heo t...@kernel.org Cc: Viresh Kumar viresh.ku...@linaro.org Cc: Frederic Weisbecker

[PATCH 1/3 V7] workqueue: split apply_workqueue_attrs() into 3 stages

2015-04-07 Thread Lai Jiangshan
into wq_pool_mutex. this is needed to avoid to do the further splitting. Suggested-by: Tejun Heo t...@kernel.org Cc: Christoph Lameter c...@linux.com Cc: Kevin Hilman khil...@linaro.org Cc: Lai Jiangshan la...@cn.fujitsu.com Cc: Mike Galbraith bitbuc...@online.de Cc: Paul E. McKenney paul

  1   2   3   4   5   6   7   8   9   10   >