From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753768AbdCPPsT (ORCPT ); Thu, 16 Mar 2017 11:48:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753391AbdCPPsR (ORCPT ); Thu, 16 Mar 2017 11:48:17 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AB3A5811A7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=oleg@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AB3A5811A7 Date: Thu, 16 Mar 2017 16:46:15 +0100 From: Oleg Nesterov To: Tejun Heo Cc: Linus Torvalds , Andrew Morton , Peter Zijlstra , Thomas Gleixner , Chris Mason , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 1/2] kthread: add barriers to set_kthread_struct() and to_kthread() Message-ID: <20170316154614.GB26391@redhat.com> References: <20170315231827.GA13656@htj.duckdns.org> <20170316145436.GA24478@redhat.com> <20170316153301.GA15810@htj.duckdns.org> <20170316153843.GB15810@htj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170316153843.GB15810@htj.duckdns.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 16 Mar 2017 15:48:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/16, Tejun Heo wrote: > > On Thu, Mar 16, 2017 at 11:33:01AM -0400, Tejun Heo wrote: > > > And perhaps we should add another helper, say, > > > > > > #define lockless_assign_pointer(ptr, val) \ > > > smp_store_release(&ptr, val) > > > > > > for set_kthread_struct() ? it can have more users. > > > > > > Not that I think you should change your patch, I am just asking. > > > > Ah yeah, that would look better. I vaguely remembered the new macro > > but couldn't quite remember it fully. :) Will update the patch. > > Oops, as for adding lockless_assign_pointer(), wouldn't smp_wmb() be a > better match for smp_read_barrier_depends()? ISTR acquire/release > pairs being more expensive on some archs. No, no, don't ask me, I can't know ;) But. Note that rcu_assign_pointer() (which should pair with smp_read_barrier_depends/lockless_dereference too) uses smp_store_release(), and the changelog says "potentially less overhead". See 88c1863066ccfa456 "rcu: Define rcu_assign_pointer() in terms of smp_store_release()". And this discussion is another argument to add the new helper, we can always change it to use wmb or store_release, or whatever else. Plus arch/ can overwrite it. Oleg.