Skip to content

Commit

Permalink
Merge tag 'driver-core-6.0-rc5' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/gregkh/driver-core

Pull driver core fixes from Greg KH:
 "Here are some small driver core and debugfs fixes for 6.0-rc5.

  Included in here are:

   - multiple attempts to get the arch_topology code to work properly on
     non-cluster SMT systems. First attempt caused build breakages in
     linux-next and 0-day, second try worked.

   - debugfs fixes for a long-suffering memory leak. The pattern of
     debugfs_remove(debugfs_lookup(...)) turns out to leak dentries, so
     add debugfs_lookup_and_remove() to fix this problem. Also fix up
     the scheduler debug code that highlighted this problem. Fixes for
     other subsystems will be trickling in over the next few months for
     this same issue once the debugfs function is merged.

  All of these have been in linux-next since Wednesday with no reported
  problems"

* tag 'driver-core-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  arch_topology: Make cluster topology span at least SMT CPUs
  sched/debug: fix dentry leak in update_sched_domain_debugfs
  debugfs: add debugfs_lookup_and_remove()
  driver core: fix driver_set_override() issue with empty strings
  Revert "arch_topology: Make cluster topology span at least SMT CPUs"
  arch_topology: Make cluster topology span at least SMT CPUs
  • Loading branch information
torvalds committed Sep 9, 2022
2 parents 9ebc0ec + 5ac251c commit e35be05
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/base/arch_topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ const struct cpumask *cpu_clustergroup_mask(int cpu)
*/
if (cpumask_subset(cpu_coregroup_mask(cpu),
&cpu_topology[cpu].cluster_sibling))
return get_cpu_mask(cpu);
return topology_sibling_cpumask(cpu);

return &cpu_topology[cpu].cluster_sibling;
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/base/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ int driver_set_override(struct device *dev, const char **override,
if (len >= (PAGE_SIZE - 1))
return -EINVAL;

/*
* Compute the real length of the string in case userspace sends us a
* bunch of \0 characters like python likes to do.
*/
len = strlen(s);

if (!len) {
/* Empty string passed - clear override */
device_lock(dev);
Expand Down
22 changes: 22 additions & 0 deletions fs/debugfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,28 @@ void debugfs_remove(struct dentry *dentry)
}
EXPORT_SYMBOL_GPL(debugfs_remove);

/**
* debugfs_lookup_and_remove - lookup a directory or file and recursively remove it
* @name: a pointer to a string containing the name of the item to look up.
* @parent: a pointer to the parent dentry of the item.
*
* This is the equlivant of doing something like
* debugfs_remove(debugfs_lookup(..)) but with the proper reference counting
* handled for the directory being looked up.
*/
void debugfs_lookup_and_remove(const char *name, struct dentry *parent)
{
struct dentry *dentry;

dentry = debugfs_lookup(name, parent);
if (!dentry)
return;

debugfs_remove(dentry);
dput(dentry);
}
EXPORT_SYMBOL_GPL(debugfs_lookup_and_remove);

/**
* debugfs_rename - rename a file/directory in the debugfs filesystem
* @old_dir: a pointer to the parent dentry for the renamed object. This
Expand Down
6 changes: 6 additions & 0 deletions include/linux/debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ struct dentry *debugfs_create_automount(const char *name,
void debugfs_remove(struct dentry *dentry);
#define debugfs_remove_recursive debugfs_remove

void debugfs_lookup_and_remove(const char *name, struct dentry *parent);

const struct file_operations *debugfs_real_fops(const struct file *filp);

int debugfs_file_get(struct dentry *dentry);
Expand Down Expand Up @@ -225,6 +227,10 @@ static inline void debugfs_remove(struct dentry *dentry)
static inline void debugfs_remove_recursive(struct dentry *dentry)
{ }

static inline void debugfs_lookup_and_remove(const char *name,
struct dentry *parent)
{ }

const struct file_operations *debugfs_real_fops(const struct file *filp);

static inline int debugfs_file_get(struct dentry *dentry)
Expand Down
2 changes: 1 addition & 1 deletion kernel/sched/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void update_sched_domain_debugfs(void)
char buf[32];

snprintf(buf, sizeof(buf), "cpu%d", cpu);
debugfs_remove(debugfs_lookup(buf, sd_dentry));
debugfs_lookup_and_remove(buf, sd_dentry);
d_cpu = debugfs_create_dir(buf, sd_dentry);

i = 0;
Expand Down

0 comments on commit e35be05

Please sign in to comment.