From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752553AbZCOEEZ (ORCPT ); Sun, 15 Mar 2009 00:04:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751411AbZCOEEQ (ORCPT ); Sun, 15 Mar 2009 00:04:16 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:34394 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbZCOEEP (ORCPT ); Sun, 15 Mar 2009 00:04:15 -0400 Date: Sat, 14 Mar 2009 20:51:05 -0700 From: Andrew Morton To: Frederic Weisbecker Cc: Ingo Molnar , Linux Kernel Mailing List , Peter Zijlstra , Steven Rostedt , tglx@linutronix.de, Jason Baron , "Frank Ch. Eigler" , Mathieu Desnoyers , KOSAKI Motohiro , Lai Jiangshan , Jiaying Zhang , Michael Rubin , Martin Bligh , Michael Davidson Subject: Re: [PATCH 1/2 v2] tracing/syscalls: core infrastructure for syscalls tracing Message-Id: <20090314205105.b67bdb6a.akpm@linux-foundation.org> In-Reply-To: <1236955332-10133-2-git-send-email-fweisbec@gmail.com> References: <1236955332-10133-1-git-send-email-fweisbec@gmail.com> <1236955332-10133-2-git-send-email-fweisbec@gmail.com> X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Mar 2009 15:42:11 +0100 Frederic Weisbecker wrote: > +void start_ftrace_syscalls(void) > +{ > + unsigned long flags; > + struct task_struct *g, *t; > + > + if (atomic_inc_return(&refcount) != 1) > + goto out; > + > + arch_init_ftrace_syscalls(); > + read_lock_irqsave(&tasklist_lock, flags); > + > + do_each_thread(g, t) { > + set_tsk_thread_flag(t, TIF_SYSCALL_FTRACE); > + } while_each_thread(g, t); > + > + read_unlock_irqrestore(&tasklist_lock, flags); > +out: > + atomic_dec(&refcount); > +} > + > +void stop_ftrace_syscalls(void) > +{ > + unsigned long flags; > + struct task_struct *g, *t; > + > + if (atomic_dec_return(&refcount)) > + goto out; > + > + read_lock_irqsave(&tasklist_lock, flags); > + > + do_each_thread(g, t) { > + clear_tsk_thread_flag(t, TIF_SYSCALL_FTRACE); > + } while_each_thread(g, t); > + > + read_unlock_irqrestore(&tasklist_lock, flags); > +out: > + atomic_inc(&refcount); > +} What is this `refcount' thing trying to do? afacit it does not prevent the two loops from running concurrently and making a mess. If it _is_ trying to prevent that from happening, then why not use plain old mutex_lock()? If the code is or some reason correct then it certainly is not sufficiently obvious to be let uncommented.