Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
locking/atomic, kref: Add KREF_INIT()
Browse files Browse the repository at this point in the history
Since we need to change the implementation, stop exposing internals.

Provide KREF_INIT() to allow static initialization of struct kref.

Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Peter Zijlstra authored and reocat committed Jan 14, 2024
1 parent 4669b85 commit 4417478
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/block/drbd/drbd_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned
.done = 0,
.flags = flags,
.error = 0,
.kref = { ATOMIC_INIT(2) },
.kref = KREF_INIT(2),
};

if (!get_ldev_if_state(device, D_ATTACHING)) { /* put is in drbd_bm_aio_ctx_destroy() */
Expand Down
2 changes: 1 addition & 1 deletion fs/fuse/fuse_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct fuse_io_priv {

#define FUSE_IO_PRIV_SYNC(f) \
{ \
.refcnt = { ATOMIC_INIT(1) }, \
.refcnt = KREF_INIT(1), \
.async = 0, \
.file = f, \
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/kref.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct kref {
atomic_t refcount;
};

#define KREF_INIT(n) { .refcount = ATOMIC_INIT(n), }

/**
* kref_init - initialize object.
* @kref: object in question.
Expand Down
4 changes: 1 addition & 3 deletions init/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ int version_string(LINUX_VERSION_CODE);
#endif

struct uts_namespace init_uts_ns = {
.kref = {
.refcount = ATOMIC_INIT(2),
},
.kref = KREF_INIT(2),
.name = {
.sysname = UTS_SYSNAME,
.nodename = UTS_NODENAME,
Expand Down
4 changes: 1 addition & 3 deletions kernel/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ static inline int mk_pid(struct pid_namespace *pid_ns,
* the scheme scales to up to 4 million PIDs, runtime.
*/
struct pid_namespace init_pid_ns = {
.kref = {
.refcount = ATOMIC_INIT(2),
},
.kref = KREF_INIT(2),
.pidmap = {
[ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
},
Expand Down

0 comments on commit 4417478

Please sign in to comment.