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=-5.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 B3019C4361B for ; Wed, 9 Dec 2020 19:14:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D15F23C41 for ; Wed, 9 Dec 2020 19:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387617AbgLITOn (ORCPT ); Wed, 9 Dec 2020 14:14:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387603AbgLITOm (ORCPT ); Wed, 9 Dec 2020 14:14:42 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFA6C0613D6 for ; Wed, 9 Dec 2020 11:14:02 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id u18so4619487lfd.9 for ; Wed, 09 Dec 2020 11:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z3Nmrur31MwA2YAFkLrqIIvFJlFJK1KzSVW0MgYqjnU=; b=iF8p7WSVKFaLPoiil/apBE7Bc/WIgYkkC2eeoVYJyiSsI93Shgjg2pmgj5T42cFNdT dQVofMSyw/O7oowlMT0vQ1v9J6nvT5o0lYVaPwlYwvdR2TSfvxKirHUV9mUSQpwQ0rCj LYzfVONNcmJCuJemyMspDvLrySVvj5A434PDo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z3Nmrur31MwA2YAFkLrqIIvFJlFJK1KzSVW0MgYqjnU=; b=K53VTN1RyFKRW7l79iJhunQNlZH9/szOJyWRfC57+ak3lCv+ZENgEKcGxAbxZAzsGB +tUjA/kJD7WSthrFI9wdMNNO/M4VZdgs3rY4efUt49C5e+p4qmau0TheFmKSkA5EraOT tL0AMQzNgB74MfmjSPJgDJ8Midz7BvN/8SAX1QsBNL9kHCsol33urkahloepj6N4yry7 fresEsA3FR82i/6pQQ1tND5C2RFVrqeaZLNpq92hnasccmK86kJsJxnT+NA1ujUvXvzR jyEnQSsw4sVB4QZLaGI6gvIEV+r6NYDroBe/LrWpjnXKrEsjL1rl8OBgaaTSqvV0k+fV y3Dg== X-Gm-Message-State: AOAM531QxJ/ymARVfGufgGOW0f9cqhfZx7b0ODnolpUDpaxmyhNGYg9L +yl1WwpEwZ3Ei5paEsHnLVnrBXZhOYsY5A== X-Google-Smtp-Source: ABdhPJx66y1xGmYiMV8cbPRsV5zdv6wsmy1z4Na/g8OTpvpJ5+kivmCrq3qj1jj3B/hfcpuu0iTJWA== X-Received: by 2002:a19:7415:: with SMTP id v21mr1323959lfe.343.1607541240517; Wed, 09 Dec 2020 11:14:00 -0800 (PST) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id e27sm299628ljb.6.2020.12.09.11.13.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 11:13:59 -0800 (PST) Received: by mail-lf1-f42.google.com with SMTP id m12so4631155lfo.7 for ; Wed, 09 Dec 2020 11:13:59 -0800 (PST) X-Received: by 2002:a19:7d85:: with SMTP id y127mr1439263lfc.253.1607541239067; Wed, 09 Dec 2020 11:13:59 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <87o8j2svnt.fsf_-_@x220.int.ebiederm.org> From: Linus Torvalds Date: Wed, 9 Dec 2020 11:13:38 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] files: rcu free files_struct To: "Eric W. Biederman" Cc: Al Viro , Linux Kernel Mailing List , linux-fsdevel , Christian Brauner , Oleg Nesterov , Jann Horn Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Dec 9, 2020 at 10:05 AM Eric W. Biederman wrote: > > - struct file * file = xchg(&fdt->fd[i], NULL); > + struct file * file = fdt->fd[i]; > if (file) { > + rcu_assign_pointer(fdt->fd[i], NULL); This makes me nervous. Why did we use to do that xchg() there? That has atomicity guarantees that now are gone. Now, this whole thing should be called for just the last ref of the fd table, so presumably that atomicity was never needed in the first place. But the fact that we did that very expensive xchg() then makes me go "there's some reason for it". Is this xchg() just bogus historical leftover? It kind of looks that way. But maybe that change should be done separately? Linus