From owner-svn-src-all@freebsd.org Sun Dec 13 18:56:24 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D75544C0960; Sun, 13 Dec 2020 18:56:24 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CvDJS4zhsz4l65; Sun, 13 Dec 2020 18:56:24 +0000 (UTC) (envelope-from arichardson.kde@gmail.com) Received: by mail-ed1-f42.google.com with SMTP id r5so14843647eda.12; Sun, 13 Dec 2020 10:56:24 -0800 (PST) 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=LeQP1ZRaaG5esb04MOnBHfU9qVQVZfua8eegrMvHW/o=; b=apbSLn+7JM5ajte3RmxiSJCWs6cJQ0cBYStWe9jHT2Gwy5GLsy0TyOfVKbYitRr3XJ qsPwnHARwRdfAQglov7suqHQ409EzbDaPynp+IiHV822zET56+bsFuYyhiSRXKF8hBlm n252aBSDDDUo4zaQJ8C5aPIxLQEVW50CYH9PIaLJHocnpbl3W94I4ScV7TeWj0vD1ttA 95Jwdp63NunvPTSO/JfqnzcfE7kOAzb4hkj7hUvAmIW/VU1lXQfYvGMrfH66LB9K1L0O lJkR1KuQnz9PoTwNQHRgc3WeeY18CTIAuSRt0/iq02cIPY9TgeWhLzBry0DvDXXpUoxG wbEg== X-Gm-Message-State: AOAM531+lHYA7fXOU+geTo9GsSddqWIImjt08iw9NHcFwHq1gA97I9wf y7wP/Dm4kjB48dtIZqCvIis3EjAjBqvKLQ== X-Google-Smtp-Source: ABdhPJzzRvAmDv0hjHC86h7CpO1ssnr6UkSOuhECwRQ4Ps6PsU8H8em9LsD7I0c+G1XYWVJeLEDdzw== X-Received: by 2002:aa7:c543:: with SMTP id s3mr21495854edr.88.1607885783204; Sun, 13 Dec 2020 10:56:23 -0800 (PST) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com. [209.85.221.48]) by smtp.gmail.com with ESMTPSA id ho12sm11320349ejc.45.2020.12.13.10.56.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Dec 2020 10:56:22 -0800 (PST) Received: by mail-wr1-f48.google.com with SMTP id 91so14244491wrj.7; Sun, 13 Dec 2020 10:56:22 -0800 (PST) X-Received: by 2002:a5d:6cc2:: with SMTP id c2mr14438738wrc.374.1607885782457; Sun, 13 Dec 2020 10:56:22 -0800 (PST) MIME-Version: 1.0 References: <202012131806.0BDI6Puj082474@repo.freebsd.org> In-Reply-To: <202012131806.0BDI6Puj082474@repo.freebsd.org> From: Alexander Richardson Date: Sun, 13 Dec 2020 18:56:11 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r368609 - in head/sys: kern sys To: Mateusz Guzik Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4CvDJS4zhsz4l65 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Dec 2020 18:56:24 -0000 On Sun, 13 Dec 2020 at 18:06, Mateusz Guzik wrote: > > Author: mjg > Date: Sun Dec 13 18:06:24 2020 > New Revision: 368609 > URL: https://svnweb.freebsd.org/changeset/base/368609 > > Log: > fd: fix fdrop prediction when closing a fd > > Most of the time this is the last reference, contrary to typical fdrop use. > > Modified: > head/sys/kern/kern_descrip.c > head/sys/sys/file.h > > Modified: head/sys/kern/kern_descrip.c > ============================================================================== > --- head/sys/kern/kern_descrip.c Sun Dec 13 16:26:37 2020 (r368608) > +++ head/sys/kern/kern_descrip.c Sun Dec 13 18:06:24 2020 (r368609) > @@ -2766,7 +2766,7 @@ closef(struct file *fp, struct thread *td) > FILEDESC_XUNLOCK(fdp); > } > } > - return (fdrop(fp, td)); > + return (fdrop_close(fp, td)); > } > > /* > > Modified: head/sys/sys/file.h > ============================================================================== > --- head/sys/sys/file.h Sun Dec 13 16:26:37 2020 (r368608) > +++ head/sys/sys/file.h Sun Dec 13 18:06:24 2020 (r368609) > @@ -299,6 +299,17 @@ fhold(struct file *fp) > _error; \ > }) > > +#define fdrop_close(fp, td) ({ \ > + struct file *_fp; \ > + int _error; \ > + \ > + _error = 0; \ > + _fp = (fp); \ > + if (__predict_true(refcount_release(&_fp->f_count))) \ > + _error = _fdrop(_fp, td); \ > + _error; \ > +}) > + > static __inline fo_rdwr_t fo_read; > static __inline fo_rdwr_t fo_write; > static __inline fo_truncate_t fo_truncate; Wouldn't this be more readable as a static __inline function (or if you are concerned about it not being inlined, __always_inline)? Also means you can drop the temporary _fp variable that's there to avoid side-effects in macro args. Regards, Alex