From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 5F8D72F6929 for ; Mon, 17 Nov 2025 10:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763376969; cv=none; b=BHjKPRPUL1phbYiurJ2gUz8zSxlaEo/Bf2E+AXMXMkSfEeHMLQt58Z+n3obFMmvw3NxZ/XfJ4p1iWJ6oQb+nKEf9WKtF1AjSOVj6Dps/lhwew39lxi0VMxDs0xznQNf8C4GMRPQ0CU1P1f2qeQkAYd9XOtGaS0D+PmqOnjhev1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763376969; c=relaxed/simple; bh=5Fch4VOyOBVrPSeTqiBnQID9v/xjNjcswLUJiPC/rIU=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=cpvZ9NgO0mYIw3mw1CfB6ZB9hE8Kef0sg5NV+QQyHX/O3oEbBn/Esij1SK2lVOVVNc1VMYdoPQ1bD9eeG8cD5c2r9D4NJvCRgU+3cFBNHnngNBq3TfZrou6cr93plOEr+tYRxhl+VRZ/+/VeBUpPNfKt29YWpShu/HrCIvYC1Y0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=nfWeXZZF; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Q89CvPjJ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=HhVSJVVP; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=7yYEu2g0; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="nfWeXZZF"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Q89CvPjJ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HhVSJVVP"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7yYEu2g0" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E34121F44F; Mon, 17 Nov 2025 10:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1763376964; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qoJVWWDzKhrx7TTsS5LL+fRrXYWx8GLDiy9e21W9Xn0=; b=nfWeXZZFnOEkUHI2BJv2ej/Y36+xRxHXvWnWXvW1y6lPMIuU9UnTAU5Q4kW9OqRQo4x5ZX S6A5BKU3vN7I399LajHk5LVWW+Zu/qxemOE2dxVUdHSW/FG8PHDlRT+D2DGUw0Q9owQ6GS nr4i4rPwHwBbu66zNtTqQY5cBToFmsw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1763376964; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qoJVWWDzKhrx7TTsS5LL+fRrXYWx8GLDiy9e21W9Xn0=; b=Q89CvPjJVbz3F/soo+gsrOp+YCCPGH+bvBFuc5WKW4ZQ3s1FHMH4DdWVYkR/NGTszV3dZL vZ4AInL3e2XfExDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1763376963; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qoJVWWDzKhrx7TTsS5LL+fRrXYWx8GLDiy9e21W9Xn0=; b=HhVSJVVPhXD1lCvjkApnnR2Qjq/PCaZ6Vjt5QK7UhMbwfa+3fY0bZ0G9d/EjFRf7QhPR0h OaMxkTNmolu29I0JG2RKcyaye8LtJJoIJ7nvHEMG5UrokM0ahsOg7uqDS30Zq8oN0Jrwmo rPXSuhCXx6cUt+GwsEiOQxIjXwPyo/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1763376963; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qoJVWWDzKhrx7TTsS5LL+fRrXYWx8GLDiy9e21W9Xn0=; b=7yYEu2g0+lXtG0ZVjDmMqYUgRsdWc4Ky2WKHBiMushxRc3Q0RA2Doy5qinMT55SfbP9kIs bdKQvOnt4W0N72Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A63AB3EA61; Mon, 17 Nov 2025 10:56:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 7CWqJkP/Gmm5YQAAD6G6ig (envelope-from ); Mon, 17 Nov 2025 10:56:03 +0000 Date: Mon, 17 Nov 2025 11:56:02 +0100 From: Jean Delvare To: linux-mm@kvack.org Cc: LKML , David Hildenbrand , Oscar Salvador , SeongJae Park Subject: [PATCH v2 1/2] mm/cma: Inline cma_sysfs counter hooks Message-ID: <20251117115602.7b9c7ccd@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 4.2.0 (GTK 3.24.43; x86_64-suse-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; HAS_ORG_HEADER(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Score: -3.80 Move cma_sysfs counter hooks from cma_sysfs.c to cma.c. These one-liner functions are only used once each, but the compiler currently can't inline them because they are defined in one object and used in another. Letting the compiler inline these functions lowers the footprint and runtime cost of the sysfs interface to CMA stats even more. Signed-off-by: Jean Delvare --- Changes in v2: * Move the functions to cma.c as this is the only place where they are used. mm/cma.c | 27 +++++++++++++++++++++++++++ mm/cma.h | 12 ------------ mm/cma_sysfs.c | 15 --------------- 3 files changed, 27 insertions(+), 27 deletions(-) --- linux-6.17.orig/mm/cma.h +++ linux-6.17/mm/cma.h @@ -80,16 +80,4 @@ static inline unsigned long cma_bitmap_m return cmr->count >> cma->order_per_bit; } -#ifdef CONFIG_SYSFS -void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages); -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) {}; -static inline void cma_sysfs_account_fail_pages(struct cma *cma, - unsigned long nr_pages) {}; -static inline void cma_sysfs_account_release_pages(struct cma *cma, - unsigned long nr_pages) {}; -#endif #endif --- linux-6.17.orig/mm/cma_sysfs.c +++ linux-6.17/mm/cma_sysfs.c @@ -14,21 +14,6 @@ #define CMA_ATTR_RO(_name) \ static struct kobj_attribute _name##_attr = __ATTR_RO(_name) -void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages) -{ - atomic64_add(nr_pages, &cma->nr_pages_succeeded); -} - -void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages) -{ - atomic64_add(nr_pages, &cma->nr_pages_failed); -} - -void cma_sysfs_account_release_pages(struct cma *cma, unsigned long nr_pages) -{ - atomic64_add(nr_pages, &cma->nr_pages_released); -} - static inline struct cma *cma_from_kobj(struct kobject *kobj) { return container_of(kobj, struct cma_kobject, kobj)->cma; --- linux-6.17.orig/mm/cma.c +++ linux-6.17/mm/cma.c @@ -36,6 +36,33 @@ struct cma cma_areas[MAX_CMA_AREAS]; unsigned int cma_area_count; +#ifdef CONFIG_SYSFS +static void cma_sysfs_account_success_pages(struct cma *cma, + unsigned long nr_pages) +{ + atomic64_add(nr_pages, &cma->nr_pages_succeeded); +} + +static void cma_sysfs_account_fail_pages(struct cma *cma, + unsigned long nr_pages) +{ + atomic64_add(nr_pages, &cma->nr_pages_failed); +} + +static void cma_sysfs_account_release_pages(struct cma *cma, + unsigned long nr_pages) +{ + atomic64_add(nr_pages, &cma->nr_pages_released); +} +#else +static void cma_sysfs_account_success_pages(struct cma *cma, + unsigned long nr_pages) {}; +static void cma_sysfs_account_fail_pages(struct cma *cma, + unsigned long nr_pages) {}; +static void cma_sysfs_account_release_pages(struct cma *cma, + unsigned long nr_pages) {}; +#endif + phys_addr_t cma_get_base(const struct cma *cma) { WARN_ON_ONCE(cma->nranges != 1); -- Jean Delvare SUSE L3 Support