Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130Ab3FYQAK (ORCPT ); Tue, 25 Jun 2013 12:00:10 -0400 Received: from mga09.intel.com ([134.134.136.24]:36932 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269Ab3FYQAI (ORCPT ); Tue, 25 Jun 2013 12:00:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,938,1363158000"; d="scan'208";a="359345372" Subject: Re: [PATCH 2/2] rwsem: do optimistic spinning for writer lock acquisition From: Tim Chen To: Peter Zijlstra Cc: Peter Hurley , Davidlohr Bueso , Alex Shi , Michel Lespinasse , Ingo Molnar , Andrew Morton , Andrea Arcangeli , Andi Kleen , Matthew R Wilcox , Dave Hansen , Rik van Riel , linux-kernel@vger.kernel.org, linux-mm In-Reply-To: <20130625073739.GX28407@twins.programming.kicks-ass.net> References: <1371858700.22432.5.camel@schen9-DESK> <51C558E2.1040108@hurleysoftware.com> <1372017836.1797.14.camel@buesod1.americas.hpqcorp.net> <1372093876.22432.34.camel@schen9-DESK> <51C894C3.4040407@hurleysoftware.com> <1372105065.22432.65.camel@schen9-DESK> <20130625073739.GX28407@twins.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" Date: Tue, 25 Jun 2013 09:00:06 -0700 Message-ID: <1372176006.22432.96.camel@schen9-DESK> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 (2.32.3-1.fc14) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 848 Lines: 28 On Tue, 2013-06-25 at 09:37 +0200, Peter Zijlstra wrote: > On Mon, Jun 24, 2013 at 01:17:45PM -0700, Tim Chen wrote: > > On second thought, I agree with you. I should change this to > > something like > > > > int retval = true; > > task_struct *sem_owner; > > > > /* Spin only if active writer running */ > > if (!sem->owner) > > return false; > > > > rcu_read_lock(); > > sem_owner = sem->owner; > > That should be: sem_owner = ACCESS_ONCE(sem->owner); to make sure the > compiler doesn't try and be clever and rereads. Thanks. Will incorporate this in next version of the patch. Tim -- 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/