pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Subject: [PATCH v1 1/2] Use C11 alignas in typedef definitions
Date: Tue, 24 Feb 2026 09:21:19 +0000

They were already using pg_attribute_aligned.  This replaces that with
alignas and moves that into the required syntactic position.

Suggested-by: Peter Eisentraut <peter@eisentraut.org>
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/d7a788fa-e609-4894-a8be-2f70e135424f%40eisentraut.org
---
 src/backend/storage/aio/method_io_uring.c | 16 ++++++++--------
 src/include/storage/proc.h                | 13 +++++--------
 2 files changed, 13 insertions(+), 16 deletions(-)
  58.1% src/backend/storage/aio/
  41.8% src/include/storage/

inline patch 1: src/backend/storage/aio/method_io_uring.c, src/include/storage/proc.h (+13/-16 lines) download inline-1.patchdiff --git a/src/backend/storage/aio/method_io_uring.c b/src/backend/storage/aio/method_io_uring.c index ed6e71bcd46..50ea9f8e51c 100644 --- a/src/backend/storage/aio/method_io_uring.c +++ b/src/backend/storage/aio/method_io_uring.c @@ -77,15 +77,15 @@ const IoMethodOps pgaio_uring_ops = { .wait_one = pgaio_uring_wait_one, }; -/* - * Per-backend state when using io_method=io_uring - * - * Align the whole struct to a cacheline boundary, to prevent false sharing - * between completion_lock and prior backend's io_uring_ring. - */ -typedef struct pg_attribute_aligned (PG_CACHE_LINE_SIZE) -PgAioUringContext +/* Per-backend state when using io_method=io_uring */ +typedef struct PgAioUringContext { + /* + * Align the whole struct to a cacheline boundary, to prevent false + * sharing between completion_lock and prior backend's io_uring_ring. + */ + alignas(PG_CACHE_LINE_SIZE) + /* * Multiple backends can process completions for this backend's io_uring * instance (e.g. when the backend issuing IO is busy doing something diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index a8d2e7db1a1..fe798d350f1 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -180,6 +180,11 @@ typedef enum */ typedef struct PGPROC { + /* + * Align the struct at cache line boundaries. This is just for + * performance, to avoid false sharing. + */ + alignas(PG_CACHE_LINE_SIZE) dlist_head *procgloballist; /* procglobal list that owns this PGPROC */ dlist_node freeProcsLink; /* link in procgloballist, when in recycled * state */ @@ -375,14 +380,6 @@ typedef struct PGPROC uint32 wait_event_info; /* proc's wait information */ } - -/* - * If compiler understands aligned pragma, use it to align the struct at cache - * line boundaries. This is just for performance, to avoid false sharing. - */ -#if defined(pg_attribute_aligned) - pg_attribute_aligned(PG_CACHE_LINE_SIZE) -#endif PGPROC; extern PGDLLIMPORT PGPROC *MyProc; -- 2.34.1
--fe1S3SCuJMoalI5t Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0002-Use-C11-alignas-in-more-tricky-typedef-definition.patch"

Message-ID: <no-message-id-493@localhost>
Permalink:  ../no-message-id-493@localhost/
Also on:    postgresql.org/message-id/no-message-id-493@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: bertranddrouvot.pg@gmail.com
  Subject: Re: [PATCH v1 1/2] Use C11 alignas in typedef definitions
  In-Reply-To: <no-message-id-493@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox