From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913Ab3KRW6q (ORCPT ); Mon, 18 Nov 2013 17:58:46 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:53638 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751521Ab3KRW6p (ORCPT ); Mon, 18 Nov 2013 17:58:45 -0500 Date: Mon, 18 Nov 2013 14:58:41 -0800 From: "Paul E. McKenney" To: anish singh Cc: =?utf-8?B?6Z+p56OK?= , Linux Kernel Mailing List Subject: Re: list_head and lock? Message-ID: <20131118225841.GI4138@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13111822-8236-0000-0000-000003EECDA1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 17, 2013 at 05:48:14PM -0800, anish singh wrote: > On Sun, Nov 17, 2013 at 5:19 PM, 韩磊 wrote: > > when we delete,add,search,amend the list_head,should we use spinlock > > or rcu in case of conflicit to list_head??? > There is no implicit locking when we use 'list' api's.You should explicitly > do that AFAIK. See Documentation/RCU/listRCU.txt for a summary of how to use RCU-protected linked lists. But yes, readers need to explicitly do rcu_read_lock() and rcu_read_unlock(), and updaters must coordinate with each others somehow, for example, explicitly using spinlocks. The list_head macros are about list manipulation and not so much about synchronization. Thanx, Paul