From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 930FD430BBA for ; Mon, 2 Mar 2026 06:32:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772433160; cv=none; b=aKdnYZcNBeQ8qT+7XuL5Q/rvBRNYxoMPy++vQzo3cyv3KBLSaJ0onqsItbKPR9CIzjbGhDWLtFm121CWQWuXS1W9awQmTqPDXgbe1NA+kA8jGyreUcJJR+f0p7seCSMMQdYgJ9IvTLFHzCelWFziwF5+PQKSobh+NK2fGEgQ7qo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772433160; c=relaxed/simple; bh=yJ+98Fa2laTZoRic6uSfTJK/oWmOP57TWZGAlSC3+W0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=SHbiluL+MWUvfpm41Ygeua1S09kvbPPv7/PNqg/py/32UbhFplu2p4/Gr1kBWZkwr8dy+Vk8GPv0wSZEYBFyVIi/UtTy+qU39HmosssYz8iL2cl1ZAEz9QyBljg93G+Zmj/nWSn6oUmXETpL8ysA44nTgLIQPGPXSn+5MQZuTLA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=WGwgbI0v; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="WGwgbI0v" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772433158; h=from:from:reply-to:subject:subject: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=t4Y3lXimfkEu/Z+RQ7yEhHXGwPE0NSCAuBGp2KDMHhk=; b=WGwgbI0vPfYBVN0YtQKDn8Ku3G3NICgGwrxgORkDdBwxtLmu9gs1Lrqjj42oW+ReoAHuMy 7GFxJQpxDDhbk6iQOaCdkFsXHz/usZNrBJAYdojP8Cg1nDf+wBtyYkEiaEW4Jo6XJqDY7l QUUJ5l1JSyASpkFkDmELqYLyQmtBbgA= From: wen.yang@linux.dev To: Joel Granados Cc: linux-kernel@vger.kernel.org, Wen Yang Subject: [RFC PATCH v3 0/2] sysctl: refactor ctl_table initialization Date: Mon, 2 Mar 2026 14:32:19 +0800 Message-Id: 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=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Wen Yang The main motivation for this series is to avoid treewide patch series. Historically, changes to how struct ctl_table entries are initialized (e.g. removing the child field, const-qualifying ctl_table) required touching hundreds of files across all subsystems. Such series require the attention of many maintainers, sometimes need to be pulled into mainline in a special way, and create lots of unnecessary churn. By introducing a family of CTLTBL_ENTRY_XXX() helper macros in , any future structural changes to struct ctl_table can be handled in one place — the macro definition — without requiring a treewide sweep of all callers. Individual subsystem maintainers can also migrate their sysctl tables to use the macros at their own pace, without any coordinated effort. This series: 1. Introduces the CTLTBL_ENTRY_XXX() macros in include/linux/sysctl.h, allowing callers to initialize struct ctl_table entries indirectly via the macro instead of assigning each field directly. The macros use _Generic() for automatic type detection and proc_handler selection, provide smart defaults (auto address-of, auto maxlen via sizeof), and include compile-time validation of name, mode, and handler. 2. Converts kernel/sysctl-test.c to use the new macros as a demonstration, replacing direct struct ctl_table field assignments with CTLTBL_ENTRY_XXX() calls. Four new tests are added to cover the previously untested variants (CTLTBL_ENTRY_V, VN, VNM, VNMH), bringing the total to 16 passing tests. Thanks Joel's suggestions and guidance: [1] https://sysctl-dev-rtd.readthedocs.io/en/latest/notes/ctltable_entry_macro.html#table-entry-macro [2] https://lore.kernel.org/all/psot4oeauxi3yyj2w4ajm3tfgtcsvao4rhv5sgd5s6ymmjgojk@p3vrj3qluban/ Wen Yang (2): sysctl: introduce CTLTBL_ENTRY_XXX() helper macros sysctl: convert kernel/sysctl-test.c to use CTLTBL_ENTRY_XXX() include/linux/sysctl.h | 302 +++++++++++++++++++++++++++++++++++++++++ kernel/sysctl-test.c | 240 ++++++++++++++++++-------------- kernel/sysctl.c | 2 + 3 files changed, 445 insertions(+), 99 deletions(-) -- 2.25.1