From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D4B4C19425 for ; Wed, 9 Dec 2020 22:08:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D82CE23D1F for ; Wed, 9 Dec 2020 22:08:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388590AbgLIWHz (ORCPT ); Wed, 9 Dec 2020 17:07:55 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:41826 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388326AbgLIWHo (ORCPT ); Wed, 9 Dec 2020 17:07:44 -0500 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kn7bz-0059tg-AI; Wed, 09 Dec 2020 15:07:03 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1kn7bv-0004QI-Jp; Wed, 09 Dec 2020 15:07:02 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Matthew Wilcox Cc: Al Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Linus Torvalds , Christian Brauner , Oleg Nesterov , Jann Horn References: <87r1on1v62.fsf@x220.int.ebiederm.org> <20201120231441.29911-15-ebiederm@xmission.com> <20201207232900.GD4115853@ZenIV.linux.org.uk> <877dprvs8e.fsf@x220.int.ebiederm.org> <20201209040731.GK3579531@ZenIV.linux.org.uk> <877dprtxly.fsf@x220.int.ebiederm.org> <20201209142359.GN3579531@ZenIV.linux.org.uk> <87o8j2svnt.fsf_-_@x220.int.ebiederm.org> <20201209194938.GS7338@casper.infradead.org> Date: Wed, 09 Dec 2020 16:06:21 -0600 In-Reply-To: <20201209194938.GS7338@casper.infradead.org> (Matthew Wilcox's message of "Wed, 9 Dec 2020 19:49:38 +0000") Message-ID: <877dpqprc2.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1kn7bv-0004QI-Jp;;;mid=<877dpqprc2.fsf@x220.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+CaXIkETEianRwMvPYKmQ6uf9fDkRkFWk= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH] files: rcu free files_struct X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Matthew Wilcox writes: > On Wed, Dec 09, 2020 at 12:04:38PM -0600, Eric W. Biederman wrote: >> @@ -397,8 +397,9 @@ static struct fdtable *close_files(struct files_struct * files) >> set = fdt->open_fds[j++]; >> while (set) { >> if (set & 1) { >> - struct file * file = xchg(&fdt->fd[i], NULL); >> + struct file * file = fdt->fd[i]; >> if (file) { >> + rcu_assign_pointer(fdt->fd[i], NULL); > > Assuming this is safe, you can use RCU_INIT_POINTER() here because you're > storing NULL, so you don't need the wmb() before storing the pointer. Thanks. I was remembering there was a special case like and I had forgotten what the rule was. Eric