From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj2-f9.google.com (mail-pj2-f9.google.com [74.125.227.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75AFF39D6EC for ; Sat, 15 Aug 2026 10:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.137 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786789991; cv=none; b=Y86dmtDyryaHdufj5E9jo2cRFODpn+6aLdLZphc0aTLhvHVhLx0RybgXVF3E9oULqHujRDCpUbc5/gkVQkD5U5FuCMegsSTqVR35ZzjplgWjWc7z2mVB+G9GAbtnlyRHdQ9n+cl/2kt2DGI8Fxo/A9J4DYgcoxHRTLwTtGjNQjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786789991; c=relaxed/simple; bh=xt2Ap6mQATKcPO8zz5YrRvMb5+dOotonRVywXVYwaEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ne5XI+92S/IhfwtIGqyAclwomQxdOpkq3+4VAjVVubGGhx+ZD/HjXrl432wo79vTMMxSijTBQ61YeCzv3vSMfTv2KIc4UR6qGAdMc+tRkOQ+xleUcyiTZfK+FWj1BsDNVWYS97rH5AV4YXycMxDcNwEmvII4/8Q8mmC+xRXDdg4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m3NfVGgk; arc=none smtp.client-ip=74.125.227.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m3NfVGgk" Received: by mail-pj2-f9.google.com with SMTP id 98e67ed59e1d1-38f0f8ab050so1612978a91.0 for ; Sat, 15 Aug 2026 03:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786789990; x=1787394790; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HvsygzwWhr39S6cCyUe3E5mHMzXLSAHL3vic+/R/AUE=; b=m3NfVGgkAzWi2jhud7dC27it1uS8mrhIkrJ6rRljOUr84NX81CqHtB6qHVBYXILGBK 0JzzJidpJ0V/Dym6PS9uhXJx2ET86r1NwPYM48Bgyr/18Mm9Csf8wIlvoKnHrliJxpJt 0u+YipSu7AdaMqNd62vc5XEg8ssjpR7sHAkTZ1Pn+8QAKmaotKm0iBsY95q2oEUmQYq0 fRF5x6KaQY5//aZ+L1oSX9W9YC7TAGzfmOIkFdoXHsLAWnxYzarcZwDHUlDEVY7LWKL8 kOuawU2YSuRS8YHmCK1kRWusHab2MI5wHSUJ6VGgbhHzyP1NOZSh2uHxWc+020la1jHw oxpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786789990; x=1787394790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=HvsygzwWhr39S6cCyUe3E5mHMzXLSAHL3vic+/R/AUE=; b=CUwFF9djUIKLrLAgN3QckOVxfM0AROW2DvwGpq0gY78YazEl+KYN65sWldXuDOCYLQ BjAVt4hDJb02dRf/vv+YgwrI/lEj7wE9QmQDJ+7JXWz2uCj4GsamRiYMTqAq5gw0jTe+ JDRT14I65gHGDezZ695at2SLsBqGGWUz9jhm6YHyn1fWhnxM+O7KAVlPM2RhayBn2R83 o3VXF3JDv4bIp1JAOXTG2v1wjDXVb11yXQ4PZM1QXQZ2O07oI7rHJb1iTC+RZw63214M aO6juU6T4dzMEl1TjuwA5quqRg2O9vAVcEgjez+zpniXyyRiKli+uU/ANoofIH2emp1z /tww== X-Forwarded-Encrypted: i=1; AHgh+Rr1KkVyyyALvsi6QowSGB1l6F07vPsDa59JDpABSuOkQLp+NFDljVa5HWn2uaIAZvA2k0P1siCvUMqv6n4=@vger.kernel.org X-Gm-Message-State: AOJu0YwRp0lxhj2oriHlE4rhJ9i3zZUjBna0LygWC4Y+y2iUn8Wff9CY ckFhW9rBz7dpJ8yhUZPPLtHQz4i/hFENuq6hLOhR/oeSqsqPB7HVtZUP X-Gm-Gg: AR+sD11WpZlscXiJGefOMQMKyxNCs6L5gpihQzcbJfP773iXBCWxZ0auoj15F57wvDt K/JNCIh2Wx0hgFCnwmdnM4buKv+BmdcmH9CSBVXV5lSTfnJjCrN1tyyQCj527+d086YjTOhm6MT tNzjF4HmFLCsLbXY/PuDGbdz+jIh7Bnpj9qTx0SXhu4iE1xT0RiHCG9XBoqPVJqJrhs6kh0ZrjK C4FDkVSg9kzz34RRmTKcsaX+rIno6cyf0hCBXgKITa6G5ixxya8zkA5yXexeEDW6N38g3sV6YcH xay5dzbTIv+GbPmTKWDs16WmvBX3md6xhMOp1D6OGkrSGX4oA2iuhyOyPPYnqVhHPyeT7wHmGIj zOLURLZ8BmBZo0CmvHGWXBCJh3yIO/pUzdBDycowEE2AVwTMNfnb2zBnpLjWpl2dMdM23aXW3ng inwGZ5qVJOSTP0oDcSbvOblwWoT5TUEmuuW1Kugez2DwhSzG9y4zHH2zas+psyxRQsEfbmaNJkA oBrkCx0EzZ1DEE= X-Received: by 2002:a17:90b:5745:b0:38e:49c0:75a7 with SMTP id 98e67ed59e1d1-3933b7a6986mr15068609a91.8.1786789989739; Sat, 15 Aug 2026 03:33:09 -0700 (PDT) Received: from Ubuntu-172-24-64-1.localdomain ([157.37.161.135]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1413889bca5sm25815861c88.12.2026.08.15.03.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 03:33:09 -0700 (PDT) From: Eamon Sippy To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Eamon Sippy Subject: [PATCH v2] mm: cma: make mm/cma.h self-contained and conditionalize includes Date: Sat, 15 Aug 2026 10:32:45 +0000 Message-ID: <20260815103246.5315-1-eamon112009@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260815084026.44078-1-eamon112009@gmail.com> References: <20260815084026.44078-1-eamon112009@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit mm/cma.h uses types from , , and without explicitly including them, violating the kernel header self-containment guidelines. and 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 inside the CONFIG_CMA_SYSFS block, and move inside CONFIG_CMA_DEBUGFS. Remove spurious trailing semicolons after the empty inline function bodies in the CONFIG_CMA_SYSFS #else branch. Add so that MAX_CMA_AREAS and CMA_MAX_NAME are always available when this header is included. Changes in v2: - Drop inaccurate spinlock comment; the lock also protects available_count and allocation checks (Barry) Signed-off-by: Eamon Sippy --- mm/cma.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mm/cma.h b/mm/cma.h index c70180c36559..68e574b0f951 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -2,13 +2,24 @@ #ifndef __MM_CMA_H__ #define __MM_CMA_H__ +#include +#include +#include +#include +#include + +#ifdef CONFIG_CMA_DEBUGFS #include +#endif + +#ifdef CONFIG_CMA_SYSFS #include struct cma_kobject { struct kobject kobj; struct cma *cma; }; +#endif /* * Multi-range support. This can be useful if the size of the allocation @@ -37,10 +48,10 @@ struct cma_memrange { #define CMA_MAX_RANGES 8 struct cma { - unsigned long count; - unsigned long available_count; + unsigned long count; + unsigned long available_count; unsigned int order_per_bit; /* Order of pages represented by one bit */ - spinlock_t lock; + spinlock_t lock; struct mutex alloc_mutex; #ifdef CONFIG_CMA_DEBUGFS struct hlist_head mem_head; @@ -86,10 +97,11 @@ void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages); void cma_sysfs_account_release_pages(struct cma *cma, unsigned long nr_pages); #else static inline void cma_sysfs_account_success_pages(struct cma *cma, - unsigned long nr_pages) {}; + unsigned long nr_pages) {} static inline void cma_sysfs_account_fail_pages(struct cma *cma, - unsigned long nr_pages) {}; + unsigned long nr_pages) {} static inline void cma_sysfs_account_release_pages(struct cma *cma, - unsigned long nr_pages) {}; + unsigned long nr_pages) {} #endif + #endif -- 2.43.0