Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752750Ab3IUS6Y (ORCPT ); Sat, 21 Sep 2013 14:58:24 -0400 Received: from mail-vc0-f176.google.com ([209.85.220.176]:55519 "EHLO mail-vc0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521Ab3IUS6V (ORCPT ); Sat, 21 Sep 2013 14:58:21 -0400 MIME-Version: 1.0 In-Reply-To: <1379788235.2145.48.camel@buesod1.americas.hpqcorp.net> References: <1379300677-24188-1-git-send-email-davidlohr@hp.com> <1379625742.2145.19.camel@buesod1.americas.hpqcorp.net> <1379700524.5434.22.camel@flatline.rdu.redhat.com> <1379788235.2145.48.camel@buesod1.americas.hpqcorp.net> Date: Sat, 21 Sep 2013 11:58:20 -0700 X-Google-Sender-Auth: MvunxR5qFYRwZosA3OH3tgELr90 Message-ID: Subject: Re: [PATCH 0/4] ipc: shm and msg fixes From: Linus Torvalds To: Davidlohr Bueso Cc: Eric Paris , Manfred Spraul , Andrew Morton , Rik van Riel , Mike Galbraith , Sedat Dilek , Linux Kernel Mailing List , Stephen Smalley , James Morris , LSM List , Casey Schaufler Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2005 Lines: 62 On Sat, Sep 21, 2013 at 11:30 AM, Davidlohr Bueso wrote: > > IPC uses security_xxx_free() at two levels: for freeing the structure > (ie: shm_destroy()) and cleaning up upon error when creating the > structure (ie: newseg()). For both I believe we can actually use RCU. > What do you think of the below change, it is specific for shm, and we'd > need an equivalent for msq and sems. Ugh. This code already has rcu-delaying, usign the existing "rcu" list entry. I hate how you add a *new* rcu list entry, and we basically case two callbacks. More importantly, it's wrong. You do the call_rcu() unconditionally, but it might not be the last use! You need to do it with the same logic ipc_rcu_putref(), namely at the dropping of the last reference. So how about just making ipc_rcu_putref() have a RCU callback argument, and make the code look something like ipc_rcu_putref(shp, shm_rcu_free); and then shm_rcu_free() just does #define ipc_rcu_to_struct(p) ((void *)(p+1)) void shm_rcu_free(struct rcu_head *head) { struct ipc_rcu *p = container_of(head, struct ipc_rcu, rcu); struct shmid_kernel *shp = ipc_rcu_to_struct(p); security_shm_free(shp); ipc_rcu_free(head); } (that "ipc_rcu_free()" would do the current vfree-vs-kfree, just not rcu-delayed, so it would look something like void ipc_rcu_free(struct rcu_head *head) { struct ipc_rcu *p = container_of(head, struct ipc_rcu, rcu); if (is_vmalloc_addr(p)) vfree(p); else kfree(p); } Other users would then just use ipc_rcu_putref(shp, ipc_rcu_free); until they too decide that they want to do something extra at RCU freeing time.. Hmm? Linus -- 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/