Re: [PATCH] mm: cma: make mm/cma.h self-contained and conditionalize includes

Barry Song <[email protected]>
Newsgroups org.kvack.linux-mm,org.kernel.vger.linux-kernel
Message-ID <CAGsJ_4zvttvJbCdi=9FTrfq=XbJm4F=dYfmLmd8r7LH4s_TO1A@mail.gmail.com>
On Sat, Aug 15, 2026 at 4:41 PM Eamon Sippy <[email protected]> wrote:
>
> mm/cma.h uses types from <linux/spinlock.h>, <linux/mutex.h>,
> <linux/atomic.h> and <linux/list.h> without explicitly including them,
> violating the kernel header self-containment guidelines.
>
> <linux/debugfs.h> and <linux/kobject.h> are also included unconditionally
> even though they are only needed under CONFIG_CMA_DEBUGFS and
> CONFIG_CMA_SYSFS respectively. Move the struct cma_kobject definition and
> <linux/kobject.h> inside the CONFIG_CMA_SYSFS block, and move
> <linux/debugfs.h> inside CONFIG_CMA_DEBUGFS.
>
> Remove spurious trailing semicolons after the empty inline function bodies
> in the CONFIG_CMA_SYSFS #else branch.
>
> Add <linux/cma.h> so that MAX_CMA_AREAS and CMA_MAX_NAME are always
> available when this header is included.
>
> Signed-off-by: Eamon Sippy <[email protected]>
[...]
> +       unsigned long available_count;
>         unsigned int order_per_bit; /* Order of pages represented by one bit */
> -       spinlock_t      lock;
> +       spinlock_t lock;        /* protects allocation bitmap */

I’m not convinced this lock is only for protecting the bitmap. It also
protects things such as cma->available_count and the allocation checks
around page_range_contiguous(). Could we drop the added comment or
use a more accurate description?

>         struct mutex alloc_mutex;

Best Regards
Barry
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.