From nobody Fri Jan 31 20:01:42 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yl6Gz1HgRz5myLS; Fri, 31 Jan 2025 20:01:47 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yl6Gz0p1nz3NQ1; Fri, 31 Jan 2025 20:01:47 +0000 (UTC) (envelope-from bz@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738353707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1JNUiwujMmF4XqANJyN/towGhDYRrAvsjmfeIm96Kxs=; b=vP40CtxERsxvDba+stlOnS6KdydCCvgmf7U9Zi/KAV4EM+6COwsynFzmrVjfA9dIqE+wBy 3nL2zq2r97TXjhKEYLF9Otk/mwWldQgX8t52wLYUM8M6bytYvOqgWDhNDzM8Sskmojf76N JVjYsEHy2yCGc9OIFehiuYlGbpV5+HEz/CmBUxS2QMbPfauFfunPBJGmE4CRNRINxZXt7j 1rxpk55BfEm/06Ier6Wpz6Jkkc3wQ39MungHd8EagIa2s+SaV0lUnvYTe/0oKsEVMa5sRJ vhduWbCcuGsvWxZ6lCL6avIa0BNz4Vf61LxRqJhCcVeXXN7nXjUj8rQh4zPBmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738353707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1JNUiwujMmF4XqANJyN/towGhDYRrAvsjmfeIm96Kxs=; b=a+2/vSyGTR1Tl7SN3s7kwdy4TMqO7P7isQjtUULYcRs5JgDi+0I9ZHj3IVN566pgwuf1Vv Ucd0SJJCbE1vSib2R0g1AD5LlsRfbu94kBuDN1IoVo934SStOEVWP1aqXUeQ5519SVSsZ/ fjZ4sS4/T1Ava7H1o2i+NDIRJ0pSCSgeBY63ou5YXELrghqrvgcMu0Dk5DbcONpc1xeLz8 ubXeo9iRUjU1PeX12NIgHTpIF9uyGCqEVrhT5RTtRRZgctO0R2kbmxgb6RUOdTVDAOz3Jr Xb7Z9hKARad3EaLsrNmxSioZiSUKZ6V6HftZwq8wqvypGvlMOBmwwmAKX/VKiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738353707; a=rsa-sha256; cv=none; b=TFmQ/p3hWAa9NGEc92Dp6pw1jOXWmK/BitgE5och66l7Woj7yLiivugMWP1zr/80WyItax l6MxtCGIVdQe/1ofm0KPEJ5svRym3nzCRWERpADDLnD/oL+qsyEfScaM0IkRRwV8Jddu6U KyEwl8rvJwCerPGe9T1kSy0hJcQOUuvG8bygsLCieTT/9PwXFswJt/1owEFzClm3T0UGGH r1M475rulmFoo3me0/beNj8m72oZQ1INWYHmnxHqHGf3vrV2jst7dSnXsMbrTcvtjbQbrb YntdwLSzsg5Gb0msxoPkN0JXt0vQoO7Bb76nsQ5gHcZlK3w6fdBkvSxd3GfE2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from mx-01.divo.sbone.de (mx-01.divo.sbone.de [IPv6:2003:a:140a:2200:6:594:fffe:19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature ECDSA (prime256v1) client-digest SHA256) (Client CN "mx-01.divo.sbone.de", Issuer "E6" (verified OK)) (Authenticated sender: bz/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Yl6Gy5HYczmPL; Fri, 31 Jan 2025 20:01:46 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:1025]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by mx-01.divo.sbone.de (Postfix) with ESMTPS id 90846A64805; Fri, 31 Jan 2025 20:01:44 +0000 (UTC) Received: from content-filter.t4-02.sbone.de (content-filter.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:2742]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id D007C2D029DD; Fri, 31 Jan 2025 20:01:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:4902:0:7404:2:1025]) by content-filter.t4-02.sbone.de (content-filter.t4-02.sbone.de [IPv6:fde9:577b:c1a9:4902:0:7404:2:2742]) (amavisd-new, port 10024) with ESMTP id ryVJsOhpUwe7; Fri, 31 Jan 2025 20:01:43 +0000 (UTC) Received: from strong-iwl0.sbone.de (strong-iwl0.sbone.de [IPv6:fde9:577b:c1a9:4902:b66b:fcff:fef3:e3d2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 327EC2D029D8; Fri, 31 Jan 2025 20:01:43 +0000 (UTC) Date: Fri, 31 Jan 2025 20:01:42 +0000 (UTC) From: "Bjoern A. Zeeb" To: =?UTF-8?Q?Jean-S=C3=A9bastienP=C3=A9dron?= cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: 1de8fcf419fc - main - linuxkpi: Add Linux 6.7 `get_file_rcu()` variant In-Reply-To: <202501311603.50VG3LPI038815@gitrepo.freebsd.org> Message-ID: <75qr66qs-97pq-0501-9p09-qqrr10s038o3@SerrOFQ.bet> References: <202501311603.50VG3LPI038815@gitrepo.freebsd.org> X-OpenPGP-Key-Id: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1098556516-676978768-1738353703=:2254" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1098556516-676978768-1738353703=:2254 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Fri, 31 Jan 2025, Jean-SébastienPédron wrote: > The branch main has been updated by dumbbell: > > URL: https://cgit.FreeBSD.org/src/commit/?id=1de8fcf419fce890474271215dce3b6e4876b60a > > commit 1de8fcf419fce890474271215dce3b6e4876b60a > Author: Jean-Sébastien Pédron > AuthorDate: 2025-01-01 13:11:14 +0000 > Commit: Jean-Sébastien Pédron > CommitDate: 2025-01-31 16:00:49 +0000 > > linuxkpi: Add Linux 6.7 `get_file_rcu()` variant > > [Why] > In Linux 6.7, the signature of `get_file_rcu()` changed significantly, > going from: > > bool get_file_rcu(struct linux_file *f); > > ... to: > > struct linux_file * get_file_rcu(struct linux_file **f); > > I.e., both the argument and the return value changed in an incompatible > way. > > This is used by the i915 DRM driver. > > [How] > This patch introduces the variant and hide the new prototype behind > `LINUXKPI_VERSION >= 60700`. I was under the impression that current version should always be the default while older versions should be hidden behind a special #ifdef as otherwise you end up setting LINUXKPI_VERSION for all drivers very soon to get the current versions and you cannot unset it to get older versions and if you are sitting between two of these checks it won't work. > Reviewed by: manu > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D48756 > --- > sys/compat/linuxkpi/common/include/linux/fs.h | 5 ++++ > sys/compat/linuxkpi/common/src/linux_compat.c | 39 +++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h > index d277b717423f..86b922ac9a1d 100644 > --- a/sys/compat/linuxkpi/common/include/linux/fs.h > +++ b/sys/compat/linuxkpi/common/include/linux/fs.h > @@ -264,12 +264,17 @@ get_file(struct linux_file *f) > return (f); > } > > +struct linux_file * linux67_get_file_rcu(struct linux_file **f); > +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 60700 > +#define get_file_rcu(f) linux67_get_file_rcu(f) > +#else > static inline bool > get_file_rcu(struct linux_file *f) > { > return (refcount_acquire_if_not_zero( > f->_file == NULL ? &f->f_count : &f->_file->f_count)); > } > +#endif > > static inline struct inode * > igrab(struct inode *inode) > diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c > index ec3ccb16b47d..e5049a4b8f43 100644 > --- a/sys/compat/linuxkpi/common/src/linux_compat.c > +++ b/sys/compat/linuxkpi/common/src/linux_compat.c > @@ -75,6 +75,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1082,6 +1083,44 @@ linux_poll_wakeup(struct linux_file *filp) > spin_unlock(&filp->f_kqlock); > } > > +static struct linux_file * > +__get_file_rcu(struct linux_file **f) > +{ > + struct linux_file *file1, *file2; > + > + file1 = READ_ONCE(*f); > + if (file1 == NULL) > + return (NULL); > + > + if (!refcount_acquire_if_not_zero( > + file1->_file == NULL ? &file1->f_count : &file1->_file->f_count)) > + return (ERR_PTR(-EAGAIN)); > + > + file2 = READ_ONCE(*f); > + if (file2 == file1) > + return (file2); > + > + fput(file1); > + return (ERR_PTR(-EAGAIN)); > +} > + > +struct linux_file * > +linux67_get_file_rcu(struct linux_file **f) > +{ > + struct linux_file *file1; > + > + for (;;) { > + file1 = __get_file_rcu(f); > + if (file1 == NULL) > + return (NULL); > + > + if (IS_ERR(file1)) > + continue; > + > + return (file1); > + } > +} > + > static void > linux_file_kqfilter_detach(struct knote *kn) > { > -- Bjoern A. Zeeb r15:7 --1098556516-676978768-1738353703=:2254--