Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757621AbZGGNVo (ORCPT ); Tue, 7 Jul 2009 09:21:44 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755318AbZGGNVg (ORCPT ); Tue, 7 Jul 2009 09:21:36 -0400 Received: from mx2.redhat.com ([66.187.237.31]:46510 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753936AbZGGNVg (ORCPT ); Tue, 7 Jul 2009 09:21:36 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20090629191653.14240.44995.stgit@dev.haskins.net> References: <20090629191653.14240.44995.stgit@dev.haskins.net> To: Gregory Haskins Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org, mst@redhat.com, swhiteho@redhat.com Subject: Re: [PATCH v4] slow-work: add (module*)work->ops->owner to fix races with module clients Date: Tue, 07 Jul 2009 14:21:33 +0100 Message-ID: <15258.1246972893@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1220 Lines: 35 Gregory Haskins wrote: > + struct module *owner = work->ops->owner; > + > + work->ops->put_ref(work); > + module_put(owner); Hmmm... There needs to be an smp_mb() between the read of the module owner and the call to put_ref(), lest the CPU reorder things... However, if put_ref(), say, calls atomic_dec_and_test(), then inserting one here would be superfluous. I think documenting this will be enough - perhaps something like: (*) Release a reference on an item: void (*put_ref)(struct slow_work *work); This allows the thread pool to unpin an item by releasing the reference on it. The thread pool will not touch the item again once this has been called. This function must interpolate a general SMP memory barrier before freeing or re-using the work struct as the caller may have read the module pointer. Implying a barrier with something like atomic_dec_and_test() is sufficient. Do you agree? David -- 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/