Skip to content

Commit 0199849

Browse files
committed
sysctl: remove register_sysctl_paths()
The deprecation for register_sysctl_paths() is over. We can rejoice as we nuke register_sysctl_paths(). The routine register_sysctl_table() was the only user left of register_sysctl_paths(), so we can now just open code and move the implementation over to what used to be to __register_sysctl_paths(). The old dynamic struct ctl_table_set *set is now the point to sysctl_table_root.default_set. The old dynamic const struct ctl_path *path was being used in the routine register_sysctl_paths() with a static: static const struct ctl_path null_path[] = { {} }; Since this is a null path we can now just simplfy the old routine and remove its use as its always empty. This saves us a total of 230 bytes. $ ./scripts/bloat-o-meter vmlinux.old vmlinux add/remove: 2/7 grow/shrink: 1/1 up/down: 1015/-1245 (-230) Function old new delta register_leaf_sysctl_tables.constprop - 524 +524 register_sysctl_table 22 497 +475 __pfx_register_leaf_sysctl_tables.constprop - 16 +16 null_path 8 - -8 __pfx_register_sysctl_paths 16 - -16 __pfx_register_leaf_sysctl_tables 16 - -16 __pfx___register_sysctl_paths 16 - -16 __register_sysctl_base 29 12 -17 register_sysctl_paths 18 - -18 register_leaf_sysctl_tables 534 - -534 __register_sysctl_paths 620 - -620 Total: Before=21259666, After=21259436, chg -0.00% Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 9e7c73c commit 0199849

3 files changed

Lines changed: 4 additions & 79 deletions

File tree

fs/proc/proc_sysctl.c

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,45 +1575,33 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
15751575
}
15761576

15771577
/**
1578-
* __register_sysctl_paths - register a sysctl table hierarchy
1579-
* @set: Sysctl tree to register on
1580-
* @path: The path to the directory the sysctl table is in.
1578+
* register_sysctl_table - register a sysctl table hierarchy
15811579
* @table: the top-level table structure
15821580
*
15831581
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
15841582
* array. A completely 0 filled entry terminates the table.
15851583
* We are slowly deprecating this call so avoid its use.
1586-
*
1587-
* See __register_sysctl_table for more details.
15881584
*/
1589-
struct ctl_table_header *__register_sysctl_paths(
1590-
struct ctl_table_set *set,
1591-
const struct ctl_path *path, struct ctl_table *table)
1585+
struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
15921586
{
15931587
struct ctl_table *ctl_table_arg = table;
15941588
int nr_subheaders = count_subheaders(table);
15951589
struct ctl_table_header *header = NULL, **subheaders, **subheader;
1596-
const struct ctl_path *component;
15971590
char *new_path, *pos;
15981591

15991592
pos = new_path = kmalloc(PATH_MAX, GFP_KERNEL);
16001593
if (!new_path)
16011594
return NULL;
16021595

16031596
pos[0] = '\0';
1604-
for (component = path; component->procname; component++) {
1605-
pos = append_path(new_path, pos, component->procname);
1606-
if (!pos)
1607-
goto out;
1608-
}
16091597
while (table->procname && table->child && !table[1].procname) {
16101598
pos = append_path(new_path, pos, table->procname);
16111599
if (!pos)
16121600
goto out;
16131601
table = table->child;
16141602
}
16151603
if (nr_subheaders == 1) {
1616-
header = __register_sysctl_table(set, new_path, table);
1604+
header = __register_sysctl_table(&sysctl_table_root.default_set, new_path, table);
16171605
if (header)
16181606
header->ctl_table_arg = ctl_table_arg;
16191607
} else {
@@ -1627,7 +1615,7 @@ struct ctl_table_header *__register_sysctl_paths(
16271615
header->ctl_table_arg = ctl_table_arg;
16281616

16291617
if (register_leaf_sysctl_tables(new_path, pos, &subheader,
1630-
set, table))
1618+
&sysctl_table_root.default_set, table))
16311619
goto err_register_leaves;
16321620
}
16331621

@@ -1646,41 +1634,6 @@ struct ctl_table_header *__register_sysctl_paths(
16461634
header = NULL;
16471635
goto out;
16481636
}
1649-
1650-
/**
1651-
* register_sysctl_paths - register a sysctl table hierarchy
1652-
* @path: The path to the directory the sysctl table is in.
1653-
* @table: the top-level table structure
1654-
*
1655-
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
1656-
* array. A completely 0 filled entry terminates the table.
1657-
* We are slowly deprecating this caller so avoid future uses of it.
1658-
*
1659-
* See __register_sysctl_paths for more details.
1660-
*/
1661-
struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1662-
struct ctl_table *table)
1663-
{
1664-
return __register_sysctl_paths(&sysctl_table_root.default_set,
1665-
path, table);
1666-
}
1667-
EXPORT_SYMBOL(register_sysctl_paths);
1668-
1669-
/**
1670-
* register_sysctl_table - register a sysctl table hierarchy
1671-
* @table: the top-level table structure
1672-
*
1673-
* Register a sysctl table hierarchy. @table should be a filled in ctl_table
1674-
* array. A completely 0 filled entry terminates the table.
1675-
*
1676-
* See register_sysctl_paths for more details.
1677-
*/
1678-
struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1679-
{
1680-
static const struct ctl_path null_path[] = { {} };
1681-
1682-
return register_sysctl_paths(null_path, table);
1683-
}
16841637
EXPORT_SYMBOL(register_sysctl_table);
16851638

16861639
int __register_sysctl_base(struct ctl_table *base_table)

include/linux/sysctl.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
221221
struct ctl_table_header *__register_sysctl_table(
222222
struct ctl_table_set *set,
223223
const char *path, struct ctl_table *table);
224-
struct ctl_table_header *__register_sysctl_paths(
225-
struct ctl_table_set *set,
226-
const struct ctl_path *path, struct ctl_table *table);
227224
struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table);
228225
struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
229-
struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
230-
struct ctl_table *table);
231-
232226
void unregister_sysctl_table(struct ctl_table_header * table);
233227

234228
extern int sysctl_init_bases(void);
@@ -277,12 +271,6 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *p
277271
return NULL;
278272
}
279273

280-
static inline struct ctl_table_header *register_sysctl_paths(
281-
const struct ctl_path *path, struct ctl_table *table)
282-
{
283-
return NULL;
284-
}
285-
286274
static inline struct ctl_table_header *register_sysctl(const char *path, struct ctl_table *table)
287275
{
288276
return NULL;

scripts/check-sysctl-docs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,6 @@ curtable && /\.procname[\t ]*=[\t ]*".+"/ {
156156
}
157157
}
158158

159-
/register_sysctl_paths\(.*\)/ {
160-
match($0, /register_sysctl_paths\(([^)]+), ([^)]+)\)/, tables)
161-
if (debug) print "Attaching table " tables[2] " to path " tables[1]
162-
if (paths[tables[1]] == table) {
163-
for (entry in entries[tables[2]]) {
164-
printentry(entry)
165-
}
166-
}
167-
split(paths[tables[1]], components, "/")
168-
if (length(components) > 1 && components[1] == table) {
169-
# Count the first subdirectory as seen
170-
seen[components[2]]++
171-
}
172-
}
173-
174-
175159
END {
176160
for (entry in documented) {
177161
if (!seen[entry]) {

0 commit comments

Comments
 (0)