History log of /src/sys/compat/linuxkpi/common/include/linux/gfp.h (Results 1 – 25 of 66)
Revision Date Author Comments
# 3c9acc35 21-Jun-2025 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Add the `topology_*()` functions

... from <asm/topology.h>.

The amdgpu DRM driver started to use `topology_num_cores_per_package()`
in Linux 6.9.

Reviewed by: manu
Sponsored by: The Free

linuxkpi: Add the `topology_*()` functions

... from <asm/topology.h>.

The amdgpu DRM driver started to use `topology_num_cores_per_package()`
in Linux 6.9.

Reviewed by: manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50993

show more ...


# e3b16f53 13-Apr-2025 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Add `folio` and `folio_batch` APIs

They are used by the i915 DRM driver in Linux 6.6 (although this change
was only backported with Linux 6.7 DRM drivers).

`struct folio` simply wraps `st

linuxkpi: Add `folio` and `folio_batch` APIs

They are used by the i915 DRM driver in Linux 6.6 (although this change
was only backported with Linux 6.7 DRM drivers).

`struct folio` simply wraps `struct page` for now.

`struct folio_batch` is the same as `struct pagevec` but it works with
`struct folio` instead of `struct page` directly.

Reviewed by: bz, kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48743

show more ...


# 718d1928 14-Nov-2024 Mathieu <sigsys@gmail.com>

LinuxKPI: make linux_alloc_pages() honor __GFP_NORETRY

This is to fix slowdowns with drm-kmod that get worse over time as
physical memory become more fragmented (and probably also depending on
other

LinuxKPI: make linux_alloc_pages() honor __GFP_NORETRY

This is to fix slowdowns with drm-kmod that get worse over time as
physical memory become more fragmented (and probably also depending on
other factors).

Based on information posted in this bug report:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277476

By default, linux_alloc_pages() retries failed allocations by calling
vm_page_reclaim_contig() to attempt to free contiguous physical memory
pages. vm_page_reclaim_contig() does not always succeed and calling it
can be very slow even when it fails. When physical memory is very
fragmented, vm_page_reclaim_contig() can end up being called (and
failing) after every allocation attempt. This could cause very
noticeable graphical desktop hangs (which could last seconds).

The drm-kmod code in question attempts to allocate multiple contiguous
pages at once but does not actually require them to be contiguous. It
can fallback to doing multiple smaller allocations when larger
allocations fail. It passes alloc_pages() the __GFP_NORETRY flag in this
case.

This patch makes linux_alloc_pages() fail early (without retrying) when
this flag is passed.

[olce: The problem this patch fixes is longer and longer GUI freezes as
a machine's memory gets filled and becomes fragmented, when using amdgpu
from DRM kmod 5.15 and DRM kmod 6.1 (DRM kmod 5.10 is unaffected; newer
Linux kernel introduced an "optimization" by which a pool of pages is
filled preferentially with contiguous pages, which triggered the problem
for us). The original commit message above evokes freezes lasting
seconds, but I occasionally witnessed some lasting tens of minutes,
rendering a machine completely useless.

The patch has been reviewed for its potential impacts to other LinuxKPI
parts and our existing DRM kmods' code. In particular, there is no
other user of __GFP_NORETRY/GFP_NORETRY with Linux's alloc_pages*()
functions in our tree or DRM kmod ports.

It has also been tested extensively, by me for months against 14-STABLE
and sporadically on -CURRENT on a RX580, and by several others as
reported below and as is visible in more details in the quoted bugzilla
PR and in the initial drm-kmod issue at
https://github.com/freebsd/drm-kmod/issues/302, on a variety of other
AMD GPUs (several RX580, RX570, Radeon Pro WX5100, Green Sardine 5600G,
Ryzen 9 4900H with embedded Renoir).]

PR: 277476
Reported by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: olce
Tested by: many (olce, Pierre Pronchery, Evgenii Khramtsov, chaplina, rk)
MFC after: 2 weeks
Relnotes: yes
Sponsored by: The FreeBSD Foundation (review and part of testing)

show more ...


# cb8bfc4d 06-Jun-2024 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Move page_address definition from linux/gfp.h to linux/mm.h

To match Linux. Some future changes may depend on proper location.

Sponsored by: Serenity Cyber Security, LLC
MFC after: 1 week

LinuxKPI: Move page_address definition from linux/gfp.h to linux/mm.h

To match Linux. Some future changes may depend on proper location.

Sponsored by: Serenity Cyber Security, LLC
MFC after: 1 week
Reviewed by: bz, emaste
Differential Revision: https://reviews.freebsd.org/D45448

show more ...


# ecd1d1f1 27-May-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: remove extern from function declarations

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste (earlier version, found another two)
Differential Revision: https://revi

LinuxKPI: remove extern from function declarations

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste (earlier version, found another two)
Differential Revision: https://reviews.freebsd.org/D45386

show more ...


# 738c02ba 02-Apr-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: add dev_alloc_pages()

Add dev_alloc_pages() though it seems a weird KPI, not passing a dev
despite its name. Used by updated wireless driver.

Sponsored by: The FreeBSD Foundation
MFC aft

LinuxKPI: add dev_alloc_pages()

Add dev_alloc_pages() though it seems a weird KPI, not passing a dev
despite its name. Used by updated wireless driver.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D44588

show more ...


# 8a8e86b8 07-Dec-2023 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

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, t

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

show more ...


# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remov

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix

show more ...


# 14dcd409 24-Nov-2023 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

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 cal

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

show more ...


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 9e9c682f 31-Jul-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: reduce usage of struct vm_page and vm_page_t

We currently define (Linux) page to (FreeBSD) vm_page.
Cleanup some of the direct struct vm_page and vm_page_t declarations
and usages in the L

LinuxKPI: reduce usage of struct vm_page and vm_page_t

We currently define (Linux) page to (FreeBSD) vm_page.
Cleanup some of the direct struct vm_page and vm_page_t declarations
and usages in the Linux KPI and make them 'struct page' or
'struct page *' to prepare for more upcoming work.

This should be a NOP.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D41255

show more ...


# c0c1c599 30-Dec-2022 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Define `GFP_NOFS` in `linux/gfp.h`

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37910


# 55038a63 03-Dec-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: add simplified vesion of page_frag_cache

For the moment and the currently only consumer (mt76) add a simplified
version of the page_frag_cache. We will only accept fragement sizes up
to 1

LinuxKPI: add simplified vesion of page_frag_cache

For the moment and the currently only consumer (mt76) add a simplified
version of the page_frag_cache. We will only accept fragement sizes up
to 1 PAGE_SIZE (KASSERT) and we will always return a full page.
Should we add more consumers or small (or large) objects would become a
problem we can always add a more elaborate version.

Discussed with: markj
Reviewed by: markj (,hselasky commented as well)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37595

show more ...


# bfe6bfd7 11-Nov-2022 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Add `__GFP_NOMEMALLOC` kmalloc flag

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D36954


# 307f78f3 19-Dec-2021 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Constantly use _LINUXKPI_ prefix in include guards

MFC after: 1 week
Reviewed by: bz, emaste, hselasky, manu
Differential Revision: https://reviews.freebsd.org/D33562


# 937a05ba 04-Aug-2019 Justin Hibbits <jhibbits@FreeBSD.org>

Add necessary bits for Linux KPI to work correctly on powerpc

PowerPC, and possibly other architectures, use different address ranges for
PCI space vs physical address space, which is only mapped at

Add necessary bits for Linux KPI to work correctly on powerpc

PowerPC, and possibly other architectures, use different address ranges for
PCI space vs physical address space, which is only mapped at resource
activation time, when the BAR gets written. The DRM kernel modules do not
activate the rman resources, soas not to waste KVA, instead only mapping
parts of the PCI memory at a time. This introduces a
BUS_TRANSLATE_RESOURCE() method, implemented in the Open Firmware/FDT PCI
driver, to perform this necessary translation without activating the
resource.

In addition to system KPI changes, LinuxKPI is updated to handle a
big-endian host, by adding proper endian swaps to the I/O functions.

Submitted by: mmacy
Reported by: hselasky
Differential Revision: https://reviews.freebsd.org/D21096

show more ...


# a63915c2 28-Jul-2019 Alan Somers <asomers@FreeBSD.org>

MFHead @r350386

Sponsored by: The FreeBSD Foundation


# 8996977a 03-Jul-2019 Hans Petter Selasky <hselasky@FreeBSD.org>

Remove dead code added after r348743 in the LinuxKPI. The
LINUXKPI_VERSION macro is not defined for any compiled LinuxKPI code
which basically means __GFP_NOTWIRED is never checked when allocating
pa

Remove dead code added after r348743 in the LinuxKPI. The
LINUXKPI_VERSION macro is not defined for any compiled LinuxKPI code
which basically means __GFP_NOTWIRED is never checked when allocating
pages. This should work fine with the existing external DRM code as
long as the page wiring and unwiring is balanced.

MFC after: 3 days
Sponsored by: Mellanox Technologies

show more ...


# e532a999 20-Jun-2019 Alan Somers <asomers@FreeBSD.org>

MFHead @349234

Sponsored by: The FreeBSD Foundation


# 1ef5e651 06-Jun-2019 Mark Johnston <markj@FreeBSD.org>

Make the linuxkpi's alloc_pages() consistently return wired pages.

Previously it did this only on platforms without a direct map. This
also more closely matches Linux's semantics.

Since some DRM v

Make the linuxkpi's alloc_pages() consistently return wired pages.

Previously it did this only on platforms without a direct map. This
also more closely matches Linux's semantics.

Since some DRM v5.0 code assumes the old behaviour, use a
LINUXKPI_VERSION guard to preserve that until the out-of-tree module
is updated.

Reviewed by: hselasky, kib (earlier versions), johalun
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20502

show more ...


# 2a22df74 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339813 through r340125.


# 3d40cdf0 01-Nov-2018 Ben Widawsky <bwidawsk@FreeBSD.org>

linuxkpi: Add GFP flags needed for ttm drivers

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Requested by: bwidawsk
MFC after: 3 days
Approved by: emaste (mentor)


# 3c9acc35 21-Jun-2025 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Add the `topology_*()` functions

... from <asm/topology.h>.

The amdgpu DRM driver started to use `topology_num_cores_per_package()`
in Linux 6.9.

Reviewed by: manu
Sponsored by: The Free

linuxkpi: Add the `topology_*()` functions

... from <asm/topology.h>.

The amdgpu DRM driver started to use `topology_num_cores_per_package()`
in Linux 6.9.

Reviewed by: manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50993

show more ...


# e3b16f53 13-Apr-2025 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

linuxkpi: Add `folio` and `folio_batch` APIs

They are used by the i915 DRM driver in Linux 6.6 (although this change
was only backported with Linux 6.7 DRM drivers).

`struct folio` simply wraps `st

linuxkpi: Add `folio` and `folio_batch` APIs

They are used by the i915 DRM driver in Linux 6.6 (although this change
was only backported with Linux 6.7 DRM drivers).

`struct folio` simply wraps `struct page` for now.

`struct folio_batch` is the same as `struct pagevec` but it works with
`struct folio` instead of `struct page` directly.

Reviewed by: bz, kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48743

show more ...


# 718d1928 14-Nov-2024 Mathieu <sigsys@gmail.com>

LinuxKPI: make linux_alloc_pages() honor __GFP_NORETRY

This is to fix slowdowns with drm-kmod that get worse over time as
physical memory become more fragmented (and probably also depending on
other

LinuxKPI: make linux_alloc_pages() honor __GFP_NORETRY

This is to fix slowdowns with drm-kmod that get worse over time as
physical memory become more fragmented (and probably also depending on
other factors).

Based on information posted in this bug report:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277476

By default, linux_alloc_pages() retries failed allocations by calling
vm_page_reclaim_contig() to attempt to free contiguous physical memory
pages. vm_page_reclaim_contig() does not always succeed and calling it
can be very slow even when it fails. When physical memory is very
fragmented, vm_page_reclaim_contig() can end up being called (and
failing) after every allocation attempt. This could cause very
noticeable graphical desktop hangs (which could last seconds).

The drm-kmod code in question attempts to allocate multiple contiguous
pages at once but does not actually require them to be contiguous. It
can fallback to doing multiple smaller allocations when larger
allocations fail. It passes alloc_pages() the __GFP_NORETRY flag in this
case.

This patch makes linux_alloc_pages() fail early (without retrying) when
this flag is passed.

[olce: The problem this patch fixes is longer and longer GUI freezes as
a machine's memory gets filled and becomes fragmented, when using amdgpu
from DRM kmod 5.15 and DRM kmod 6.1 (DRM kmod 5.10 is unaffected; newer
Linux kernel introduced an "optimization" by which a pool of pages is
filled preferentially with contiguous pages, which triggered the problem
for us). The original commit message above evokes freezes lasting
seconds, but I occasionally witnessed some lasting tens of minutes,
rendering a machine completely useless.

The patch has been reviewed for its potential impacts to other LinuxKPI
parts and our existing DRM kmods' code. In particular, there is no
other user of __GFP_NORETRY/GFP_NORETRY with Linux's alloc_pages*()
functions in our tree or DRM kmod ports.

It has also been tested extensively, by me for months against 14-STABLE
and sporadically on -CURRENT on a RX580, and by several others as
reported below and as is visible in more details in the quoted bugzilla
PR and in the initial drm-kmod issue at
https://github.com/freebsd/drm-kmod/issues/302, on a variety of other
AMD GPUs (several RX580, RX570, Radeon Pro WX5100, Green Sardine 5600G,
Ryzen 9 4900H with embedded Renoir).]

PR: 277476
Reported by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: olce
Tested by: many (olce, Pierre Pronchery, Evgenii Khramtsov, chaplina, rk)
MFC after: 2 weeks
Relnotes: yes
Sponsored by: The FreeBSD Foundation (review and part of testing)

show more ...


123