From nobody Tue Dec 5 23:52:15 2023 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 4SlHQQ3WF1z53f7B; Tue, 5 Dec 2023 23:52:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4SlHQP36LKz4LLG; Tue, 5 Dec 2023 23:52:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none) Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.17.1/8.17.1) with ESMTP id 3B5NqFF0042636; Wed, 6 Dec 2023 01:52:18 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 3B5NqFF0042636 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 3B5NqFNB042635; Wed, 6 Dec 2023 01:52:15 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 6 Dec 2023 01:52:15 +0200 From: Konstantin Belousov 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: 14dcd4098374 - main - linuxkpi: `GFP_KERNEL` equals `M_NOWAIT` now Message-ID: References: <202311241731.3AOHVsEJ061730@gitrepo.freebsd.org> 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202311241731.3AOHVsEJ061730@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Spamd-Result: default: False [-2.27 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-0.86)[-0.861]; NEURAL_HAM_SHORT(-0.41)[-0.413]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_LAST(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FREEMAIL_FROM(0.00)[gmail.com]; HAS_XAW(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4SlHQP36LKz4LLG X-Spamd-Bar: -- On Fri, Nov 24, 2023 at 05:31:54PM +0000, Jean-SébastienPédron wrote: > The branch main has been updated by dumbbell: > > URL: https://cgit.FreeBSD.org/src/commit/?id=14dcd40983748596d116d91acb934a8a95ac76bc > > commit 14dcd40983748596d116d91acb934a8a95ac76bc > Author: Jean-Sébastien Pédron > AuthorDate: 2023-11-24 17:30:33 +0000 > Commit: Jean-Sébastien Pédron > CommitDate: 2023-11-24 17:31:32 +0000 > > linuxkpi: `GFP_KERNEL` equals `M_NOWAIT` now > > ... instead of `M_WAITOK`. > > [Why] > The reason is that in some places in the DRM drivers (in particular, the > framebuffer management code), kmalloc() is called from a non-sleepable > context, such as after a call to mtx_lock(8) with an MTX_DEF mutex. > > If `GFP_KERNEL` is defined as `M_WAITOK`, we hit an assertion from > witness(4). > > [How] > The definition of `GFP_KERNEL` is changed to `M_NOWAIT`. This means that > callers should verify the return value of kmalloc(). Fortunately, this > is always the case in Linux. > > Reviewed by: bz, emaste, manu > Approved by: manu > Differential Revision: https://reviews.freebsd.org/D42054 Unfortunately this broke even attach of the mlx5(4) driver. According to the 'official' Linux kernel documentation, the GFP_KERNEL flag implies sleepable context. mlx5_core uses the passed GFP flag to determine if it is called in the sleepable context, and now even initial load assumes that it cannot perform sleeping ops. See, for instance, second if() statement in the mlx5_fwp_alloc() function. I think that it is more likely that use of (FreeBSD) mutex should be replaced by sx somewhere in DRM than to try to push all possible fixes for this change.