From axboe at kernel.dk Mon Nov 3 16:16:21 2025 From: axboe at kernel.dk (Jens Axboe) Date: Mon, 03 Nov 2025 08:16:21 -0700 Subject: [PATCH] drbd: replace kmap() with kmap_local_page() in receiver path In-Reply-To: <20251101054422.17045-1-i.shihao.999@gmail.com> References: <20251101054422.17045-1-i.shihao.999@gmail.com> Message-ID: <176218298119.720460.5302997686043809131.b4-ty@kernel.dk> On Sat, 01 Nov 2025 11:14:22 +0530, Shi Hao wrote: > Use kmap_local_page() instead of kmap() to avoid > CPU contention. > > kmap() uses a global set of mapping slots that can cause contention > between multiple CPUs, while kmap_local_page() uses per-CPU slots > eliminating this contention. It also ensures non-sleeping operation > and provides better cache locality. > > [...] Applied, thanks! [1/1] drbd: replace kmap() with kmap_local_page() in receiver path commit: 77220f6d18a22b0b5d73b5d2156609b0aa21a7c5 Best regards, -- Jens Axboe From i.shihao.999 at gmail.com Sat Nov 1 06:44:22 2025 From: i.shihao.999 at gmail.com (Shi Hao) Date: Sat, 1 Nov 2025 11:14:22 +0530 Subject: [PATCH] drbd: replace kmap() with kmap_local_page() in receiver path Message-ID: <20251101054422.17045-1-i.shihao.999@gmail.com> Use kmap_local_page() instead of kmap() to avoid CPU contention. kmap() uses a global set of mapping slots that can cause contention between multiple CPUs, while kmap_local_page() uses per-CPU slots eliminating this contention. It also ensures non-sleeping operation and provides better cache locality. Convert kmap() to kmap_local_page() as it aligns with ongoing kernel efforts to modernize kmap() usage for better multi-core scalability. Signed-off-by: Shi Hao --- drivers/block/drbd/drbd_receiver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index caaf2781136d..14821420ea50 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -1736,13 +1736,13 @@ read_in_block(struct drbd_peer_device *peer_device, u64 id, sector_t sector, page = peer_req->pages; page_chain_for_each(page) { unsigned len = min_t(int, ds, PAGE_SIZE); - data = kmap(page); + data = kmap_local_page(page); err = drbd_recv_all_warn(peer_device->connection, data, len); if (drbd_insert_fault(device, DRBD_FAULT_RECEIVE)) { drbd_err(device, "Fault injection: Corrupting data on receive\n"); data[0] = data[0] ^ (unsigned long)-1; } - kunmap(page); + kunmap_local(data); if (err) { drbd_free_peer_req(device, peer_req); return NULL; @@ -1777,7 +1777,7 @@ static int drbd_drain_block(struct drbd_peer_device *peer_device, int data_size) page = drbd_alloc_pages(peer_device, 1, 1); - data = kmap(page); + data = kmap_local_page(page); while (data_size) { unsigned int len = min_t(int, data_size, PAGE_SIZE); @@ -1786,7 +1786,7 @@ static int drbd_drain_block(struct drbd_peer_device *peer_device, int data_size) break; data_size -= len; } - kunmap(page); + kunmap_local(data); drbd_free_pages(peer_device->device, page); return err; } -- 2.51.0 From hch at infradead.org Tue Nov 18 07:09:02 2025 From: hch at infradead.org (Christoph Hellwig) Date: Mon, 17 Nov 2025 22:09:02 -0800 Subject: [PATCH] drbd: add missing kernel-doc for peer_device parameter In-Reply-To: <20251117172557.355797-1-hsukrut3@gmail.com> References: <20251117172557.355797-1-hsukrut3@gmail.com> Message-ID: On Mon, Nov 17, 2025 at 10:55:56PM +0530, Sukrut Heroorkar wrote: > W=1 build warns that peer_device is undocumented in the bitmap I/O > handlers. This parameter was introduced in commit 8164dd6c8ae1 > ("drbd: Add peer device parameter to whole-bitmap I/O handlers"), but > the kernel-doc was not updated. > > Add the missing @peer_device entry. Or just make it a non-kerneldoc comment as it doesn't document an external API to start with. From christoph.boehmwalder at linbit.com Tue Nov 18 11:50:08 2025 From: christoph.boehmwalder at linbit.com (=?UTF-8?Q?Christoph_B=C3=B6hmwalder?=) Date: Tue, 18 Nov 2025 11:50:08 +0100 Subject: [PATCH] compat: make block_device_operations tests grsec compatible In-Reply-To: <20251110125924.511384-1-minipli@grsecurity.net> References: <20251110125924.511384-1-minipli@grsecurity.net> Message-ID: Am 10.11.25 um 13:59 schrieb Mathias Krause: > The grsecurity patch enforces that instances of certain types are always > constified, with the help of a compiler plugin. One of these types is > 'struct block_device_operations'. Code that tries to modify a such-typed > object will cause compiler errors, leading to wrong results for the > kernel compatibility tests. > > Change these tests to do direct type compare tests instead of trying to > modify the object, making them compatible with grsecurity kernels. > > Signed-off-by: Mathias Krause Thanks, applied: https://github.com/LINBIT/drbd/commit/376a2932bf8f44dd0a18bc70f3309f3e71e0d37d -- Christoph B?hmwalder LINBIT | Keeping the Digital World Running DRBD HA ? Disaster Recovery ? Software defined Storage From christoph.boehmwalder at linbit.com Tue Nov 18 11:51:02 2025 From: christoph.boehmwalder at linbit.com (=?UTF-8?Q?Christoph_B=C3=B6hmwalder?=) Date: Tue, 18 Nov 2025 11:51:02 +0100 Subject: [PATCH] drbd: turn bitmap I/O comments into regular block comments In-Reply-To: <20251118090753.390818-1-hsukrut3@gmail.com> References: <20251118090753.390818-1-hsukrut3@gmail.com> Message-ID: <11f8aaaa-b5de-44dc-9263-5bdb506923ac@linbit.com> Am 18.11.25 um 10:07 schrieb Sukrut Heroorkar: > W=1 build warns because the bitmap I/O comments use '/**', which > marks them as kernel-doc comments even though these functions do not > document an external API. > > Convert these comments to regular block comments so kernel-doc no > longer parses them. > > Signed-off-by: Sukrut Heroorkar > --- > See: https://lore.kernel.org/all/20251117172557.355797-1-hsukrut3 at gmail.com/t/ > > drivers/block/drbd/drbd_bitmap.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) Thanks. Acked-by: Christoph B?hmwalder -- Christoph B?hmwalder LINBIT | Keeping the Digital World Running DRBD HA ? Disaster Recovery ? Software defined Storage From axboe at kernel.dk Tue Nov 18 16:38:42 2025 From: axboe at kernel.dk (Jens Axboe) Date: Tue, 18 Nov 2025 08:38:42 -0700 Subject: [PATCH] drbd: turn bitmap I/O comments into regular block comments In-Reply-To: <20251118090753.390818-1-hsukrut3@gmail.com> References: <20251118090753.390818-1-hsukrut3@gmail.com> Message-ID: <176348032225.300553.3972505243693659876.b4-ty@kernel.dk> On Tue, 18 Nov 2025 14:37:53 +0530, Sukrut Heroorkar wrote: > W=1 build warns because the bitmap I/O comments use '/**', which > marks them as kernel-doc comments even though these functions do not > document an external API. > > Convert these comments to regular block comments so kernel-doc no > longer parses them. > > [...] Applied, thanks! [1/1] drbd: turn bitmap I/O comments into regular block comments commit: 2c6d792d4b7676e2b340df05425330452fee1f40 Best regards, -- Jens Axboe From minipli at grsecurity.net Mon Nov 10 13:59:33 2025 From: minipli at grsecurity.net (Mathias Krause) Date: Mon, 10 Nov 2025 12:59:33 -0000 Subject: [PATCH] compat: make block_device_operations tests grsec compatible Message-ID: <20251110125924.511384-1-minipli@grsecurity.net> The grsecurity patch enforces that instances of certain types are always constified, with the help of a compiler plugin. One of these types is 'struct block_device_operations'. Code that tries to modify a such-typed object will cause compiler errors, leading to wrong results for the kernel compatibility tests. Change these tests to do direct type compare tests instead of trying to modify the object, making them compatible with grsecurity kernels. Signed-off-by: Mathias Krause --- .../tests/block_device_operations_open_takes_gendisk.c | 10 +++------- .../tests/have_blk_qc_t_submit_bio.c | 6 +++++- drbd/drbd-kernel-compat/tests/have_void_submit_bio.c | 6 +++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c b/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c index d5f20fd569fb..9d77f16d09d8 100644 --- a/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c +++ b/drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c @@ -5,13 +5,9 @@ # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) #endif -int foo_open(struct gendisk *disk, unsigned int mode) -{ - return 0; -} +int foo_open(struct gendisk *disk, unsigned int mode); -void foo(void) +void foo(struct block_device_operations *ops) { - struct block_device_operations ops; - BUILD_BUG_ON(!(__same_type(ops.open, &foo_open))); + BUILD_BUG_ON(!(__same_type(ops->open, &foo_open))); } diff --git a/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c b/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c index d7f2310dfbbd..d3e6dd792ff1 100644 --- a/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c +++ b/drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c @@ -2,9 +2,13 @@ #include +#ifndef __same_type +# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + blk_qc_t submit(struct bio *bio); void foo(struct block_device_operations *ops) { - ops->submit_bio = submit; + BUILD_BUG_ON(!(__same_type(ops->submit_bio, &submit))); } diff --git a/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c b/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c index c638faf020e1..09b56a658a46 100644 --- a/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c +++ b/drbd/drbd-kernel-compat/tests/have_void_submit_bio.c @@ -2,9 +2,13 @@ #include +#ifndef __same_type +# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) +#endif + void submit(struct bio *bio); void foo(struct block_device_operations *ops) { - ops->submit_bio = submit; + BUILD_BUG_ON(!(__same_type(ops->submit_bio, &submit))); } -- 2.47.3 From hsukrut3 at gmail.com Mon Nov 17 18:25:56 2025 From: hsukrut3 at gmail.com (Sukrut Heroorkar) Date: Mon, 17 Nov 2025 22:55:56 +0530 Subject: [PATCH] drbd: add missing kernel-doc for peer_device parameter Message-ID: <20251117172557.355797-1-hsukrut3@gmail.com> W=1 build warns that peer_device is undocumented in the bitmap I/O handlers. This parameter was introduced in commit 8164dd6c8ae1 ("drbd: Add peer device parameter to whole-bitmap I/O handlers"), but the kernel-doc was not updated. Add the missing @peer_device entry. Signed-off-by: Sukrut Heroorkar --- drivers/block/drbd/drbd_bitmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index 85ca000a0564..2d26f9d2454d 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c @@ -1213,6 +1213,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned /** * drbd_bm_read() - Read the whole bitmap from its on disk location. * @device: DRBD device. + * @peer_device: Peer device for which the bitmap read is performed. */ int drbd_bm_read(struct drbd_device *device, struct drbd_peer_device *peer_device) __must_hold(local) @@ -1224,6 +1225,7 @@ int drbd_bm_read(struct drbd_device *device, /** * drbd_bm_write() - Write the whole bitmap to its on disk location. * @device: DRBD device. + * @peer_device: Peer device for which the bitmap write is performed. * * Will only write pages that have changed since last IO. */ @@ -1236,7 +1238,7 @@ int drbd_bm_write(struct drbd_device *device, /** * drbd_bm_write_all() - Write the whole bitmap to its on disk location. * @device: DRBD device. - * + * @peer_device: Peer device for which the bitmap write is performed. * Will write all pages. */ int drbd_bm_write_all(struct drbd_device *device, @@ -1258,6 +1260,7 @@ int drbd_bm_write_lazy(struct drbd_device *device, unsigned upper_idx) __must_ho /** * drbd_bm_write_copy_pages() - Write the whole bitmap to its on disk location. * @device: DRBD device. + * @peer_device: Peer device for which the bitmap write is performed. * * Will only write pages that have changed since last IO. * In contrast to drbd_bm_write(), this will copy the bitmap pages @@ -1275,6 +1278,7 @@ int drbd_bm_write_copy_pages(struct drbd_device *device, /** * drbd_bm_write_hinted() - Write bitmap pages with "hint" marks, if they have changed. * @device: DRBD device. + * @peer_device: Peer device for which the bitmap write is performed. */ int drbd_bm_write_hinted(struct drbd_device *device) __must_hold(local) { -- 2.43.0 From hsukrut3 at gmail.com Tue Nov 18 10:07:53 2025 From: hsukrut3 at gmail.com (Sukrut Heroorkar) Date: Tue, 18 Nov 2025 14:37:53 +0530 Subject: [PATCH] drbd: turn bitmap I/O comments into regular block comments Message-ID: <20251118090753.390818-1-hsukrut3@gmail.com> W=1 build warns because the bitmap I/O comments use '/**', which marks them as kernel-doc comments even though these functions do not document an external API. Convert these comments to regular block comments so kernel-doc no longer parses them. Signed-off-by: Sukrut Heroorkar --- See: https://lore.kernel.org/all/20251117172557.355797-1-hsukrut3 at gmail.com/t/ drivers/block/drbd/drbd_bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index 85ca000a0564..d90fa3e7f4cf 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c @@ -1210,7 +1210,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned return err; } -/** +/* * drbd_bm_read() - Read the whole bitmap from its on disk location. * @device: DRBD device. */ @@ -1221,7 +1221,7 @@ int drbd_bm_read(struct drbd_device *device, return bm_rw(device, BM_AIO_READ, 0); } -/** +/* * drbd_bm_write() - Write the whole bitmap to its on disk location. * @device: DRBD device. * @@ -1233,7 +1233,7 @@ int drbd_bm_write(struct drbd_device *device, return bm_rw(device, 0, 0); } -/** +/* * drbd_bm_write_all() - Write the whole bitmap to its on disk location. * @device: DRBD device. * @@ -1255,7 +1255,7 @@ int drbd_bm_write_lazy(struct drbd_device *device, unsigned upper_idx) __must_ho return bm_rw(device, BM_AIO_COPY_PAGES, upper_idx); } -/** +/* * drbd_bm_write_copy_pages() - Write the whole bitmap to its on disk location. * @device: DRBD device. * @@ -1272,7 +1272,7 @@ int drbd_bm_write_copy_pages(struct drbd_device *device, return bm_rw(device, BM_AIO_COPY_PAGES, 0); } -/** +/* * drbd_bm_write_hinted() - Write bitmap pages with "hint" marks, if they have changed. * @device: DRBD device. */ -- 2.43.0 From hsukrut3 at gmail.com Tue Nov 18 10:09:26 2025 From: hsukrut3 at gmail.com (sukrut heroorkar) Date: Tue, 18 Nov 2025 14:39:26 +0530 Subject: [PATCH] drbd: add missing kernel-doc for peer_device parameter In-Reply-To: References: <20251117172557.355797-1-hsukrut3@gmail.com> Message-ID: On Tue, Nov 18, 2025 at 11:39?AM Christoph Hellwig wrote: > > On Mon, Nov 17, 2025 at 10:55:56PM +0530, Sukrut Heroorkar wrote: > > W=1 build warns that peer_device is undocumented in the bitmap I/O > > handlers. This parameter was introduced in commit 8164dd6c8ae1 > > ("drbd: Add peer device parameter to whole-bitmap I/O handlers"), but > > the kernel-doc was not updated. > > > > Add the missing @peer_device entry. > > Or just make it a non-kerneldoc comment as it doesn't document an > external API to start with. > Thank you. I have sent another patch adhering to this suggestion.