From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 48E5237B3F6 for ; Tue, 17 Mar 2026 17:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773769002; cv=none; b=PaQ/9EqMK+H0+mgqu64sHW6QeiHMDk1/3Xx1YJP1JQpbglI4ZABv6glfNLMAp76/hANXrPDKy5YoHSqH6imY1gSbvjMVczktUJrt+zye/hu9U8kEsRv/0L5xOSs8BO8t4SrvIWrhcKF3u5LKzddLtp4vaBTc6NAWHXnp8ZCuNmo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773769002; c=relaxed/simple; bh=cEwGAMJF/2MsWjt+jT+UPD7RI+7YaWXgdfD9I318P0c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=umOvjFYl0yTwEMMs5d17/FBgyAd/Nu1A02xenEqh93RZj9Y3Dv9648w//+x1cbfxmdchObI0E9B3oG1WMTIY/6BQRVfbiAhRnsWM0hlKx7swySho8evyvSr5yAl1cogiXRfal2bB0mtVbLzHbxvfnhFgbwBplf5fy66VFgkoGJs= 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=axZ99kS5; arc=none smtp.client-ip=95.215.58.173 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="axZ99kS5" 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=1773768998; 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=75r8vx0AmEBwhT3X31P6zjm42N+s10phyDiouatpNUE=; b=axZ99kS5H+rYYauftAleG7KnY9RUet0PzxLrrGjALc2Z6Of71QOnDgm/BVjY2UxTua6EaW Nt8GfXDmCts4LZIdG9cUI5Cb5TLuEem6zWVMKQcEZ8XsCYIETiOPyo0ySBt9a8vVRxF/un ZFRwfFNVkTEGxqx7fvilQK3V+qKbFt0= From: wen.yang@linux.dev To: Joel Granados Cc: linux-kernel@vger.kernel.org, Wen Yang Subject: [RFC PATCH v4 0/2] sysctl: refactor ctl_table initialization Date: Wed, 18 Mar 2026 01:36:13 +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. Based on discussion and suggestions from: [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/ 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. --- Changes in v4: - Fix Wpointer-type-mismatch warnings detected by lkp: https://lore.kernel.org/oe-kbuild-all/202603050724.SZxrEyyu-lkp@intel.com/ Changes in v3: - replace the unique macro with "capital letter approach" - reduce the name further https://lore.kernel.org/all/rn4rsazh7kxf5byq65vw2phyqgzvwm3scczu3l5h2r4aqit2r6@znlpb24z2zuo/ Changes in v2: - add lvalue check, handler type check, etc. https://lore.kernel.org/all/xptwb3uwbzposd4xf7khj52ifv4tchcjdgllhv7aabi6d7wgef@2msurl564v53/ 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 | 294 +++++++++++++++++++++++++++++++++++++++++ kernel/sysctl-test.c | 240 +++++++++++++++++++-------------- kernel/sysctl.c | 2 + 3 files changed, 437 insertions(+), 99 deletions(-) -- 2.25.1