From nobody Thu Dec 07 20:54:43 2023 X-Original-To: dev-commits-src-main@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 4SmRNM3qTJz53bY4; Thu, 7 Dec 2023 20:54:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SmRNM3K5fz3BxV; Thu, 7 Dec 2023 20:54:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701982483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FnKd1KhDCjzdFB+yJAeqA2F4ItHkWrQv7vbjFael6V0=; b=KHkYmajvvtF0MJzmmUMVKW+zsaRt3kQeyW6AoOE9Pv0GTd4ACIHL0SoIh/N6mwGldVmt1c 0b9XxPGhs4j9bL55/dwptheayKNrqauHNCGNYgUaz/3uUflHdNCFYoH/WlAF03dQe4q/K5 tmR7equVqHr96dTUzSg+XPBk+7U5yh4mWrHUNTriKgGVvrDri17CVa0k6xVASX1e3z6sqG /KBL0eXB/MEwLIfLTH03ha3cq1rURsnez8/2ZuOSGWfIy168OgQFH7Hl1/zURjojvOOEa/ rfztvBxZVM7BUmdlzsqlDiRWFkarSo+Lno5qEQzDX+Bd4IfhOUF2304CwGzutA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701982483; a=rsa-sha256; cv=none; b=oUbgdPXAUaR6SBcFH9sgrQyQiQKi0LyiOU2hrB4xSL6L5rYLkiBwtzH2eN5rNAbvu7QT/m HJ77FEXXQFhactAs9shBxQqbNYA6FDpt6BNTM7CnV2/A7GBwBrzuRLciKoihv4Q1nCiow9 HPy3cnLTgrINpic8AKMcPJGVPNodZHTEu6vsiCRw0Cfr+NvvYNOwcpeBJc4OEutxVQyaSl RV0sFih2FtZBclrn2YXYe0l4qTATVd+IIWtIsZkqCCn4dUM/vfa5pLT4L61HCluxsZfJ+N 7RShx4poNHReqwtsXAWGAQjbkTcD/eNfvH0hY8E/TJCrS+79ga1ufPALFQEpiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701982483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FnKd1KhDCjzdFB+yJAeqA2F4ItHkWrQv7vbjFael6V0=; b=uP3hk+q7GvW8tygaWYMSbiZanA5tmn+64b9PXr/8mkB1ho2qb9r+M1BPXrE/vE/NqMgxqn 5ndtIGBAkVi88YBqr909lJbclUumeLN9wAOeYzViKiRcqoX904eLQiOa7+UjDy13RDIqu8 nUO7x7PUyW7o4EnZXMUxu+2aGTVyXhBsyg5JgDH5OPA+kqWP5zbieiJaL3nfY2ru18uxqG 8u5sfiPm42Maq4I+NpIV1EZYn4ig7xxwr8E+RHlPaGhgJt77qUiep/D+Uk5SJH0iomN54W uEEFiH2nQBWxTU0gN+DwWnPjTtfed+Ms0fnL979iE34GhvMlFFeXUCMLflNlhg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SmRNM2NYczsbc; Thu, 7 Dec 2023 20:54:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3B7Kshd1089995; Thu, 7 Dec 2023 20:54:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3B7KshSY089992; Thu, 7 Dec 2023 20:54:43 GMT (envelope-from git) Date: Thu, 7 Dec 2023 20:54:43 GMT Message-Id: <202312072054.3B7KshSY089992@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= Subject: git: 8a8e86b819dc - main - Revert "linuxkpi: `GFP_KERNEL` equals `M_NOWAIT` now" List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a8e86b819dcaf60ed0858f7b00cb733c9ae3aca Auto-Submitted: auto-generated The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=8a8e86b819dcaf60ed0858f7b00cb733c9ae3aca commit 8a8e86b819dcaf60ed0858f7b00cb733c9ae3aca Author: Jean-Sébastien Pédron AuthorDate: 2023-12-07 18:45:25 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-12-07 20:53:44 +0000 Revert "linuxkpi: `GFP_KERNEL` equals `M_NOWAIT` now" This change seems to break some drivers such as the mlx5*(4) drivers. As kib@ says: > According to the 'official' Linux kernel documentation, the GFP_KERNEL > flag implies sleepable context. It was introduced while working on the new vt(4)/DRM integration [1]. During this work, doing sleepable allocations broke vt(4) and the DRM drivers. However, I made further improvements and some locking-related fixed to the new integration without revisiting the need for it. After more testing, the improvements to the integration mentionned above seems to make the change to `GFP_KERNEL` unneeded now. I can thus revert it to restore expectations of other drivers. This reverts commit 14dcd40983748596d116d91acb934a8a95ac76bc. [1] https://github.com/freebsd/drm-kmod/pull/243 Reviewed by: kib Approved by: kib Differential Revision: https://reviews.freebsd.org/D42962 --- sys/compat/linuxkpi/common/include/linux/gfp.h | 2 +- sys/compat/linuxkpi/common/include/linux/slab.h | 8 ++++---- sys/compat/linuxkpi/common/src/linux_compat.c | 7 ++----- sys/compat/linuxkpi/common/src/linux_interrupt.c | 3 --- sys/compat/linuxkpi/common/src/linux_pci.c | 4 ++-- sys/compat/linuxkpi/common/src/linux_shmemfs.c | 11 ++--------- 6 files changed, 11 insertions(+), 24 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h index 7f59c73851b1..c086fb9effe4 100644 --- a/sys/compat/linuxkpi/common/include/linux/gfp.h +++ b/sys/compat/linuxkpi/common/include/linux/gfp.h @@ -63,7 +63,7 @@ #define GFP_NOWAIT M_NOWAIT #define GFP_ATOMIC (M_NOWAIT | M_USE_RESERVE) -#define GFP_KERNEL M_NOWAIT +#define GFP_KERNEL M_WAITOK #define GFP_USER M_WAITOK #define GFP_HIGHUSER M_WAITOK #define GFP_HIGHUSER_MOVABLE M_WAITOK diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 3e857a4adc54..8557f831bb60 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -47,12 +47,12 @@ MALLOC_DECLARE(M_KMALLOC); #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) #define kzalloc_node(size, flags, node) kmalloc_node(size, (flags) | __GFP_ZERO, node) #define kfree_const(ptr) kfree(ptr) -#define vzalloc(size) __vmalloc(size, M_WAITOK | __GFP_NOWARN | __GFP_ZERO, 0) +#define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0) #define vfree(arg) kfree(arg) #define kvfree(arg) kfree(arg) -#define vmalloc_node(size, node) __vmalloc_node(size, M_WAITOK, node) -#define vmalloc_user(size) __vmalloc(size, M_WAITOK | __GFP_ZERO, 0) -#define vmalloc(size) __vmalloc(size, M_WAITOK, 0) +#define vmalloc_node(size, node) __vmalloc_node(size, GFP_KERNEL, node) +#define vmalloc_user(size) __vmalloc(size, GFP_KERNEL | __GFP_ZERO, 0) +#define vmalloc(size) __vmalloc(size, GFP_KERNEL, 0) #define __kmalloc(...) kmalloc(__VA_ARGS__) /* diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index baa4ff2fee44..b913ae602ab3 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -574,7 +574,7 @@ linux_file_alloc(void) { struct linux_file *filp; - filp = kzalloc(sizeof(*filp), M_WAITOK); + filp = kzalloc(sizeof(*filp), GFP_KERNEL); /* set initial refcount */ filp->f_count = 1; @@ -1412,9 +1412,6 @@ linux_file_mmap_single(struct file *fp, const struct file_operations *fop, return (EINVAL); vmap = kzalloc(sizeof(*vmap), GFP_KERNEL); - if (vmap == NULL) - return (ENOMEM); - vmap->vm_start = 0; vmap->vm_end = size; vmap->vm_pgoff = *offset / PAGE_SIZE; @@ -1944,7 +1941,7 @@ vmmap_add(void *addr, unsigned long size) { struct vmmap *vmmap; - vmmap = kmalloc(sizeof(*vmmap), M_WAITOK); + vmmap = kmalloc(sizeof(*vmmap), GFP_KERNEL); mtx_lock(&vmmaplock); vmmap->vm_size = size; vmmap->vm_addr = addr; diff --git a/sys/compat/linuxkpi/common/src/linux_interrupt.c b/sys/compat/linuxkpi/common/src/linux_interrupt.c index 886a5d5ad014..5602b09c8fb8 100644 --- a/sys/compat/linuxkpi/common/src/linux_interrupt.c +++ b/sys/compat/linuxkpi/common/src/linux_interrupt.c @@ -135,9 +135,6 @@ lkpi_request_irq(struct device *xdev, unsigned int irq, GFP_KERNEL | __GFP_ZERO); else irqe = kzalloc(sizeof(*irqe), GFP_KERNEL); - if (irqe == NULL) - return (-ENOMEM); - irqe->dev = dev; irqe->res = res; irqe->arg = arg; diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index a1cddfdf6a23..99750d5ced26 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -304,7 +304,7 @@ lkpifill_pci_dev(device_t dev, struct pci_dev *pdev) pdev->subsystem_device = pci_get_subdevice(dev); pdev->class = pci_get_class(dev); pdev->revision = pci_get_revid(dev); - pdev->path_name = kasprintf(M_WAITOK, "%04d:%02d:%02d.%d", + pdev->path_name = kasprintf(GFP_KERNEL, "%04d:%02d:%02d.%d", pci_get_domain(dev), pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev)); pdev->bus = malloc(sizeof(*pdev->bus), M_DEVBUF, M_WAITOK | M_ZERO); @@ -1468,7 +1468,7 @@ linux_dma_pool_create(char *name, struct device *dev, size_t size, priv = dev->dma_priv; - pool = kzalloc(sizeof(*pool), M_WAITOK); + pool = kzalloc(sizeof(*pool), GFP_KERNEL); pool->pool_device = dev; pool->pool_entry_size = size; diff --git a/sys/compat/linuxkpi/common/src/linux_shmemfs.c b/sys/compat/linuxkpi/common/src/linux_shmemfs.c index f0ee0e36f8c6..1fb17bc5c0cb 100644 --- a/sys/compat/linuxkpi/common/src/linux_shmemfs.c +++ b/sys/compat/linuxkpi/common/src/linux_shmemfs.c @@ -47,15 +47,8 @@ linux_shmem_read_mapping_page_gfp(vm_object_t obj, int pindex, gfp_t gfp) struct page *page; int rv; - /* - * Historically, GFP_KERNEL was the equivalent of M_WAITOK. But it was - * changed to a synonym of M_NOWAIT to allow allocations in - * non-sleepable code. - * - * However, there was an assertion here to make sure that `gfp` was - * never set to GFP_NOWAIT/M_NOWAIT. Do we need a specific handling of - * M_NOWAIT here? - */ + if ((gfp & GFP_NOWAIT) != 0) + panic("GFP_NOWAIT is unimplemented"); VM_OBJECT_WLOCK(obj); rv = vm_page_grab_valid(&page, obj, pindex, VM_ALLOC_NORMAL |