Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752570AbbELFGY (ORCPT ); Tue, 12 May 2015 01:06:24 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:17981 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750765AbbELFGV (ORCPT ); Tue, 12 May 2015 01:06:21 -0400 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="92020907" Message-ID: <55518B1E.8010309@cn.fujitsu.com> Date: Tue, 12 May 2015 13:09:50 +0800 From: Lai Jiangshan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Tejun Heo CC: Subject: Re: [PATCH 3/5] workqueue: ensure attrs-changing be sequentially References: <1431336953-3260-1-git-send-email-laijs@cn.fujitsu.com> <1431336953-3260-4-git-send-email-laijs@cn.fujitsu.com> <20150511145502.GD11388@htj.duckdns.org> In-Reply-To: <20150511145502.GD11388@htj.duckdns.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.103] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2111 Lines: 77 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. > > atomic. > >> >> Process A (change cpumask) | Process B (change numa affinity) >> wq_cpumask_store() | >> wq_sysfs_prep_attrs() | > ^ > misaligned It is aligned in email, misaligned in quoted email, and misaligned in `git log` and `git show`, aligned in `git commit` when I wrote the changelog. I will just remove all the |. > >> | apply_workqueue_attrs() >> apply_workqueue_attrs() | >> >> It results that the Process B's operation is totally reverted >> without any notification. > > Yeah, right. > >> This behavior is acceptable but it is sometimes unexpected. > > I don't think this is an acceptable behavior. > >> Sequential model on non-performance-sensitive operations is more popular >> and preferred. So this patch moves wq_sysfs_prep_attrs() into the protection > > You can just say the previous behavior is buggy. It depends on definitions. To me, it is just a nuisance. > >> under 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(). > ... >> +static void apply_wqattrs_lock(void) >> +{ >> + /* >> + * CPUs should stay stable across pwq creations and installations. >> + * Pin CPUs, determine the target cpumask for each node and create >> + * pwqs accordingly. >> + */ >> + get_online_cpus(); >> + mutex_lock(&wq_pool_mutex); >> +} >> + >> +static void apply_wqattrs_unlock(void) >> +{ >> + mutex_unlock(&wq_pool_mutex); >> + put_online_cpus(); >> +} > > Separate out refactoring and extending locking coverage? > > Thanks. > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/