[PATCH] pnp: extend char array field in pnp_fixup structure
The length of id field of pnp_fixup structure is 7: struct pnp_fixup { char id[7]; void (*quirk_function) (struct pnp_dev * dev); /* fixup function */ } In other hand the field is initialized with a constant cstring consisting of 7 characters in pnp_fixups defined in drivers/pnp/quirks.c: static struct pnp_fixup pnp_fixups[] = { /* Soundblaster awe io port quirk */ {"CTL0021", quirk_awe32_resources}, {"CTL0022", quirk_awe32_resources}, The constant cstring is too large to store; no space for nul char. If the id field is just used as byte array, there is no problem. However, it is used as c string in pnp_fixup_device function: pnp_dbg(&dev->dev, "%s: calling %pF\n", f->id, f->quirk_function); Signed-off-by: Masatake YAMATO --- include/linux/pnp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 195aafc..d734ee2 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -295,7 +295,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data) } struct pnp_fixup { - char id[7]; + char id[8]; void (*quirk_function) (struct pnp_dev * dev); /* fixup function */ }; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND3 PATCH] libiscsi: avoid unnecessary multiple NULL assignments
In iscsi_free_task, NULL is assigned to task->sc twice: before and after kfifo_in invocatoin. Allocating and freeing iscsi_task are guarded with session->lock, so multiple NULL assignments cause no trouble. But people reading the source code may be confused. The second NULL assignment comes from commit: 3e5c28ad0391389959ccae81c938c7533efb3490 It seems that the line after kfifo_in invocation was introduced accidentally. Signed-off-by: Masatake YAMATO Reviewed-by: Mike Christie --- drivers/scsi/libiscsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 82c3fd4..7aacf3a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -507,7 +507,6 @@ static void iscsi_free_task(struct iscsi_task *task) kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*)); if (sc) { - task->sc = NULL; /* SCSI eh reuses commands to verify us */ sc->SCp.ptr = NULL; /* -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] net: Providing protocol type via system.sockprotoname xattr of /proc/PID/fd entries
lsof reports some of socket descriptors as "can't identify protocol" like: [yamato@localhost]/tmp% sudo lsof | grep dbus | grep iden dbus-daem 652 dbus6u sock ... 17812 can't identify protocol dbus-daem 652 dbus 34u sock ... 24689 can't identify protocol dbus-daem 652 dbus 42u sock ... 24739 can't identify protocol dbus-daem 652 dbus 48u sock ... 22329 can't identify protocol ... lsof cannot resolve the protocol used in a socket because procfs doesn't provide the map between inode number on sockfs and protocol type of the socket. For improving the situation this patch adds an extended attribute named 'system.sockprotoname' in which the protocol name for /proc/PID/fd/SOCKET is stored. So lsof can know the protocol for a given /proc/PID/fd/SOCKET with getxattr system call. A few weeks ago I submitted a patch for the same purpose. The patch was introduced /proc/net/sockfs which enumerates inodes and protocols of all sockets alive on a system. However, it was rejected because (1) a global lock was needed, and (2) the layout of struct socket was changed with the patch. This patch doesn't use any global lock; and doesn't change the layout of any structs. In this patch, a protocol name is stored to dentry->d_name of sockfs when new socket is associated with a file descriptor. Before this patch dentry->d_name was not used; it was just filled with empty string. lsof may use an extended attribute named 'system.sockprotoname' to retrieve the value of dentry->d_name. It is nice if we can see the protocol name with ls -l /proc/PID/fd. However, "socket:[#INODE]", the name format returned from sockfs_dname() was already defined. To keep the compatibility between kernel and user land, the extended attribute is used to prepare the value of dentry->d_name. Signed-off-by: Masatake YAMATO --- net/socket.c | 83 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/net/socket.c b/net/socket.c index a5471f8..977c0f4 100644 --- a/net/socket.c +++ b/net/socket.c @@ -88,6 +88,7 @@ #include #include #include +#include #include #include @@ -346,7 +347,8 @@ static struct file_system_type sock_fs_type = { * but we take care of internal coherence yet. */ -static int sock_alloc_file(struct socket *sock, struct file **f, int flags) +static int sock_alloc_file(struct socket *sock, struct file **f, int flags, + const char *dname) { struct qstr name = { .name = "" }; struct path path; @@ -357,6 +359,13 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) if (unlikely(fd < 0)) return fd; + if (dname) { + name.name = dname; + name.len = strlen(name.name); + } else if (sock->sk) { + name.name = sock->sk->sk_prot_creator->name; + name.len = strlen(name.name); + } path.dentry = d_alloc_pseudo(sock_mnt->mnt_sb, &name); if (unlikely(!path.dentry)) { put_unused_fd(fd); @@ -389,7 +398,7 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) int sock_map_fd(struct socket *sock, int flags) { struct file *newfile; - int fd = sock_alloc_file(sock, &newfile, flags); + int fd = sock_alloc_file(sock, &newfile, flags, NULL); if (likely(fd >= 0)) fd_install(fd, newfile); @@ -455,6 +464,68 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) return NULL; } +#define XATTR_SOCKPROTONAME_SUFFIX "sockprotoname" +#define XATTR_NAME_SOCKPROTONAME (XATTR_SYSTEM_PREFIX XATTR_SOCKPROTONAME_SUFFIX) +#define XATTR_NAME_SOCKPROTONAME_LEN (sizeof(XATTR_NAME_SOCKPROTONAME)-1) +static ssize_t sockfs_getxattr(struct dentry *dentry, + const char *name, void *value, size_t size) +{ + const char *proto_name; + size_t proto_size; + int error; + + error = -ENODATA; + if (!strncmp(name, XATTR_NAME_SOCKPROTONAME, XATTR_NAME_SOCKPROTONAME_LEN)) { + proto_name = dentry->d_name.name; + proto_size = strlen(proto_name); + + if (value) { + error = -ERANGE; + if (proto_size + 1 > size) + goto out; + + strncpy(value, proto_name, proto_size + 1); + } + error = proto_size + 1; + } + +out: + return error; +} + +static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer, + size_t size) +{ + ssize_t len; + ssize_t used = 0; + + len
Re: linux-next: manual merge of the net-next tree with the vfs tree
Hi, How can I see source files applied your patch? (I'm very new to kernel development.) You patch looks like a patch for another patch. Masatake YAMATO > Hi all, > > Today's linux-next merge of the net-next tree got a conflict in > net/socket.c between commits f8a78429cc70 ("take descriptor handling from > sock_alloc_file() to callers") and 32b529f92ea7 ("unexport sock_map_fd(), > switch to sock_alloc_file()") from the vfs tree and commit 600e177920df > ("net: Providing protocol type via system.sockprotoname xattr > of /proc/PID/fd entries") from the net-next tree. > > I fixed it up (see below) and can carry the fix as necessary. I also had > to add this merge fix patch: > > From: Stephen Rothwell > Date: Wed, 5 Sep 2012 11:52:06 +1000 > Subject: [PATCH] net: cope with sock_alloc_file() API change > > Signed-off-by: Stephen Rothwell > --- > include/linux/net.h |3 ++- > net/9p/trans_fd.c |2 +- > net/sctp/socket.c |2 +- > 3 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/include/linux/net.h b/include/linux/net.h > index c8a9708..a3831f3 100644 > --- a/include/linux/net.h > +++ b/include/linux/net.h > @@ -247,7 +247,8 @@ extern int sock_sendmsg(struct socket *sock, > struct msghdr *msg, > size_t len); > extern intsock_recvmsg(struct socket *sock, struct msghdr *msg, > size_t size, int flags); > -extern struct file *sock_alloc_file(struct socket *sock, int flags); > +extern struct file *sock_alloc_file(struct socket *sock, int flags, > + const char *dname); > extern struct socket *sockfd_lookup(int fd, int *err); > extern struct socket *sock_from_file(struct file *file, int *err); > #define sockfd_put(sock) fput(sock->file) > diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c > index 8c4e0b5..1c8b557 100644 > --- a/net/9p/trans_fd.c > +++ b/net/9p/trans_fd.c > @@ -801,7 +801,7 @@ static int p9_socket_open(struct p9_client *client, > struct socket *csocket) > return -ENOMEM; > > csocket->sk->sk_allocation = GFP_NOIO; > - file = sock_alloc_file(csocket, 0); > + file = sock_alloc_file(csocket, 0, NULL); > if (IS_ERR(file)) { > pr_err("%s (%d): failed to map fd\n", > __func__, task_pid_nr(current)); > diff --git a/net/sctp/socket.c b/net/sctp/socket.c > index 5ba739e..59d16ea 100644 > --- a/net/sctp/socket.c > +++ b/net/sctp/socket.c > @@ -4313,7 +4313,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int > len, char __user *optval > goto out; > } > > - newfile = sock_alloc_file(newsock, 0); > + newfile = sock_alloc_file(newsock, 0, NULL); > if (unlikely(IS_ERR(newfile))) { > put_unused_fd(retval); > sock_release(newsock); > -- > 1.7.10.280.gaa39 > > -- > Cheers, > Stephen Rothwells...@canb.auug.org.au > > diff --cc net/socket.c > index 79170dc,977c0f4..000 > --- a/net/socket.c > +++ b/net/socket.c > @@@ -346,15 -347,30 +347,23 @@@ static struct file_system_type sock_fs_ >* but we take care of internal coherence yet. >*/ > > - struct file *sock_alloc_file(struct socket *sock, int flags) > -static int sock_alloc_file(struct socket *sock, struct file **f, int flags, > - const char *dname) > ++struct file *sock_alloc_file(struct socket *sock, int flags, > ++ const char *dname) > { > struct qstr name = { .name = "" }; > struct path path; > struct file *file; > -int fd; > - > -fd = get_unused_fd_flags(flags); > -if (unlikely(fd < 0)) > -return fd; > > + if (dname) { > + name.name = dname; > + name.len = strlen(name.name); > + } else if (sock->sk) { > + name.name = sock->sk->sk_prot_creator->name; > + name.len = strlen(name.name); > + } > path.dentry = d_alloc_pseudo(sock_mnt->mnt_sb, &name); > -if (unlikely(!path.dentry)) { > -put_unused_fd(fd); > -return -ENOMEM; > -} > +if (unlikely(!path.dentry)) > +return ERR_PTR(-ENOMEM); > path.mnt = mntget(sock_mnt); > > d_instantiate(path.dentry, SOCK_INODE(sock)); > @@@ -373,26 -390,22 +382,26 @@@ > file->f_flags = O_RDWR | (flags & O_NONBLOCK); > file->f_pos = 0; > file->private_data = sock; > - > -
Re: [thermal_init] kernel BUG at net/netlink/genetlink.c:145!
> Hi Eduardo, > > I got the below dmesg and the first bad commit says that > thermal_init() is trying to register a too long group name. It may be related to my mistake. http://lists.openwall.net/netdev/2013/03/20/133 http://lists.openwall.net/netdev/2013/03/21/79 Masatake YAMATO -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/15] Proc entry showing inodes on sockfs and types
I've worked on improving lsof output on linux both lsof and linux sides. Sometimes lsof cannot resolve socket descriptors and as the result it prints them like: [yamato@localhost]/tmp% sudo lsof | grep dbus | grep iden dbus-daem 652 dbus6u sock ... 17812 can't identify protocol dbus-daem 652 dbus 34u sock ... 24689 can't identify protocol dbus-daem 652 dbus 42u sock ... 24739 can't identify protocol dbus-daem 652 dbus 48u sock ... 22329 can't identify protocol ... lsof refers /proc/net/PROTOCOL files to solve the type of socket for given socket descriptor. lsof looks up inode column of the files. lsof cannot resolve the type if there is no PROTOCOL file for PROTOCOL for the given socket descriptor nor there is PROTOCOL file with no inode column. About kernel side, bluetooth protocol families didn't have their own PROTOCOL files. So I added them. netlink protocol had its own PROTOCOL file but no inode column. So I added the column to it. About lsof side, I added code to refer /proc/net/netlink to lsof. I added code to refer /proc/net/icmp to lsof. I have to added code to refer /proc/net/PROTOCOL files for bluetooth protocol families. However, it is far from complete. $ grep -r '^\(static \)*struct proto ' | wc -l 60 It is difficult for me to deal such many protocols. During working on improving, newer protocol may be implemented. Further more subsystem mariners don't want to add inode column to /proc/net/PROTOCOL file for avoiding file format incompatibility. This patch introduces /proc/net/sockfs, which shows most of all inodes on sockfs and their socket type. A socket newly associated with socket descriptor in kernel is stored to a list named `proc_sockfs_list'. /proc/net/sockfs shows the element of the list. If a protocol has its own lsof friendly proc entry, a socket of the protocol should not be stored to `proc_sockfs_list'; lsof can solve the socket type via protocol the proc entry. A protocol can declare it has own proc entry with `has_own_proc_entry' field in struct proto. If the field is non-zero, the socket of the protocol is never added to `proc_sockfs_list'. Signed-off-by: Masatake YAMATO --- include/linux/net.h | 8 +++ include/net/sock.h | 5 ++ net/socket.c| 172 +++- 3 files changed, 183 insertions(+), 2 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index 99276c3..c87acff 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -61,6 +61,9 @@ typedef enum { #include/* For O_CLOEXEC and O_NONBLOCK */ #include #include +#ifdef CONFIG_PROC_FS +#include +#endif struct poll_table_struct; struct pipe_inode_info; @@ -135,6 +138,7 @@ struct socket_wq { * @file: File back pointer for gc * @sk: internal networking protocol agnostic socket representation * @wq: wait queue for several uses + * @proc_sockfs_list: list head to link this socket to /proc/net/sockfs */ struct socket { socket_statestate; @@ -150,6 +154,10 @@ struct socket { struct file *file; struct sock *sk; const struct proto_ops *ops; + +#ifdef CONFIG_PROC_FS + struct list_headproc_sockfs_list; +#endif }; struct vm_area_struct; diff --git a/include/net/sock.h b/include/net/sock.h index 72132ae..6697b9c 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -955,6 +955,11 @@ struct proto { void(*destroy_cgroup)(struct mem_cgroup *memcg); struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); #endif +#ifdef CONFIG_PROC_FS + /* Set non-zero value if this protocol manages its + own /proc/net/PROTOCOL entry and the entry has inode column. */ +int has_own_proc_entry; +#endif }; /* diff --git a/net/socket.c b/net/socket.c index dfe5b66..4044b58 100644 --- a/net/socket.c +++ b/net/socket.c @@ -105,6 +105,10 @@ #include #include +#ifdef CONFIG_PROC_FS +#include +#endif + static int sock_no_open(struct inode *irrelevant, struct file *dontcare); static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); @@ -127,6 +131,10 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); +static int proc_sockfs_init(void); +static void proc_sockfs_add(struct socket *sock); +static void proc_sockfs_remove(struct socket *sock); + /* * Socket files have a set of 'special' operations as well as the generic file ones. These don't appear * in the operation structures but are done directly via the socketcall() multiplexor. @@ -259,6 +267,7 @@ stati
[PATCH 02/15] Declaring udp protocols has its own proc entry
Declaring udp protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/udp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index b4c3582..2b822ac 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1963,6 +1963,9 @@ struct proto udp_prot = { .compat_getsockopt = compat_udp_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; EXPORT_SYMBOL(udp_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 03/15] Declaring icmp protocols has its own proc entry
Declaring icmp protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/ping.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 6232d47..5b4d67d 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -748,6 +748,9 @@ struct proto ping_prot = { .unhash = ping_v4_unhash, .get_port = ping_v4_get_port, .obj_size = sizeof(struct inet_sock), +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; EXPORT_SYMBOL(ping_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 04/15] Declaring udplite protocols has its own proc entry
Declaring udplite protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/udplite.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 2c46acd..0b398b5 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -62,6 +62,9 @@ struct proto udplite_prot = { .compat_getsockopt = compat_udp_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; EXPORT_SYMBOL(udplite_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 05/15] Declaring raw protocols has its own proc entry
Declaring raw protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/raw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index ff0f071..b40224d 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -901,6 +901,9 @@ struct proto raw_prot = { .compat_getsockopt = compat_raw_getsockopt, .compat_ioctl = compat_raw_ioctl, #endif +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; #ifdef CONFIG_PROC_FS -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/15] Declaring tcp protocols has its own proc entry
Declaring tcp protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/tcp_ipv4.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 272241f..e361a26 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2645,6 +2645,9 @@ struct proto tcp_prot = { .destroy_cgroup = tcp_destroy_cgroup, .proto_cgroup = tcp_proto_cgroup, #endif +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; EXPORT_SYMBOL(tcp_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 09/15] Declaring netlink protocols has its own proc entry
Declaring netlink protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/netlink/af_netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 5463969..c97b553 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -410,6 +410,9 @@ static struct proto netlink_proto = { .name = "NETLINK", .owner= THIS_MODULE, .obj_size = sizeof(struct netlink_sock), +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; static int __netlink_create(struct net *net, struct socket *sock, -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/15] Declaring tcpv6 protocols has its own proc entry
Declaring tcpv6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/tcp_ipv6.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5a439e9..9152d02 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -2043,6 +2043,9 @@ struct proto tcpv6_prot = { #ifdef CONFIG_MEMCG_KMEM .proto_cgroup = tcp_proto_cgroup, #endif +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; static const struct inet6_protocol tcpv6_protocol = { -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/15] Declaring udpv6 protocols has its own proc entry
Declaring udpv6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/udp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 99d0077..896149b 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1537,6 +1537,9 @@ struct proto udpv6_prot = { .compat_getsockopt = compat_udpv6_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; static struct inet_protosw udpv6_protosw = { -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 12/15] Declaring udplitev6 protocols has its own proc entry
Declaring udplitev6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/udplite.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 1d08e21..0d6e713 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c @@ -57,6 +57,9 @@ struct proto udplitev6_prot = { .compat_getsockopt = compat_udpv6_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; static struct inet_protosw udplite6_protosw = { -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 07/15] Declaring packet protocols has its own proc entry
Declaring packet protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/packet/af_packet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ceaca7c..4758940 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2564,6 +2564,9 @@ static struct proto packet_proto = { .name = "PACKET", .owner= THIS_MODULE, .obj_size = sizeof(struct packet_sock), +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; /* -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 13/15] Declaring rawv6 protocols has its own proc entry
Declaring rawv6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/raw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index ef0579d..15006ce 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1226,6 +1226,9 @@ struct proto rawv6_prot = { .compat_getsockopt = compat_rawv6_getsockopt, .compat_ioctl = compat_rawv6_ioctl, #endif +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; #ifdef CONFIG_PROC_FS -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 14/15] Declaring ax25 protocols has its own proc entry
Declaring ax25 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ax25/af_ax25.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 779095d..a62dd6c 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -803,6 +803,9 @@ static struct proto ax25_proto = { .name = "AX25", .owner= THIS_MODULE, .obj_size = sizeof(struct sock), +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; static int ax25_create(struct net *net, struct socket *sock, int protocol, -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 15/15] Declaring ipx protocols has its own proc entry
Declaring ipx protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipx/af_ipx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index dfd6faa..b20290d 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1345,6 +1345,9 @@ static struct proto ipx_proto = { .name = "IPX", .owner= THIS_MODULE, .obj_size = sizeof(struct ipx_sock), +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; static int ipx_create(struct net *net, struct socket *sock, int protocol, -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 08/15] Declaring unix protocols has its own proc entry
Declaring unix protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/unix/af_unix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index e4768c1..e2d9869 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -616,6 +616,9 @@ static struct proto unix_proto = { .name = "UNIX", .owner = THIS_MODULE, .obj_size = sizeof(struct unix_sock), +#ifdef CONFIG_PROC_FS + .has_own_proc_entry= 1, +#endif }; /* -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 02/15] Declaring udp protocols has its own proc entry
> On 08/10/2012 08:31 PM, Jan Ceuleers wrote: >> Two points: >> >> - I haven't seen patch 01/15; > > Correction: I have. > >> - these patches should go to netdev rather than lkml > > But this is still the case; MAINTAINERS would have told you that. Thanks. After reflecting the suggestion from Alan Cox to the patches, I will v2 patches to netdev. Masatake YAMATO -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 02/15] ipv4: declaring udp protocols has its own proc entry
Declaring udp protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/udp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index b4c3582..a16c4fa 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1963,6 +1963,7 @@ struct proto udp_prot = { .compat_getsockopt = compat_udp_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, + .has_own_proc_entry= 1, }; EXPORT_SYMBOL(udp_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 14/15] ax25: declaring ax25 protocols has its own proc entry
Declaring ax25 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ax25/af_ax25.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 779095d..ff23c8a 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -803,6 +803,7 @@ static struct proto ax25_proto = { .name = "AX25", .owner= THIS_MODULE, .obj_size = sizeof(struct sock), + .has_own_proc_entry= 1, }; static int ax25_create(struct net *net, struct socket *sock, int protocol, -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 01/15] net: proc entry showing inodes on sockfs and their types
I've worked on improving lsof output on linux both lsof and linux sides. Sometimes lsof cannot resolve socket descriptors and as the result it prints them like: [yamato@localhost]/tmp% sudo lsof | grep dbus | grep iden dbus-daem 652 dbus6u sock ... 17812 can't identify protocol dbus-daem 652 dbus 34u sock ... 24689 can't identify protocol dbus-daem 652 dbus 42u sock ... 24739 can't identify protocol dbus-daem 652 dbus 48u sock ... 22329 can't identify protocol ... lsof refers /proc/net/PROTOCOL files to solve the type of socket for given socket descriptor. lsof looks up inode column of the files. lsof cannot resolve the type if there is no PROTOCOL file for PROTOCOL for the given socket descriptor nor there is PROTOCOL file with no inode column. About kernel side, bluetooth protocol families didn't have their own PROTOCOL files. So I added them. netlink protocol had its own PROTOCOL file but no inode column. So I added the column to it. About lsof side, I added code to refer /proc/net/netlink to lsof. I added code to refer /proc/net/icmp to lsof. I have to added code to refer /proc/net/PROTOCOL files for bluetooth protocol families. However, it is far from complete. $ grep -r '^\(static \)*struct proto ' | wc -l 60 It is difficult for me to deal such many protocols. During working on improving, newer protocol may be implemented. Further more subsystem mariners don't want to add inode column to /proc/net/PROTOCOL file for avoiding file format incompatibility. This patch introduces /proc/net/sockfs, which shows most of all inodes on sockfs and their socket type. A socket newly associated with socket descriptor in kernel is stored to a list named `proc_sockfs_list'. /proc/net/sockfs shows the element of the list. If a protocol has its own lsof friendly proc entry, a socket of the protocol should not be stored to `proc_sockfs_list'; lsof can solve the socket type via protocol the proc entry. A protocol can declare it has own proc entry with `has_own_proc_entry' field in struct proto. If the field is non-zero, the socket of the protocol is never added to `proc_sockfs_list'. In v2 patch, unnecessary CONFIG_PROC_FS ifdefs are removed as suggested by Alan Cox. The patches are rebased to net-next. Signed-off-by: Masatake YAMATO --- include/linux/net.h | 8 +++ include/net/sock.h | 3 + net/socket.c| 169 +++- 3 files changed, 178 insertions(+), 2 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index 99276c3..c87acff 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -61,6 +61,9 @@ typedef enum { #include/* For O_CLOEXEC and O_NONBLOCK */ #include #include +#ifdef CONFIG_PROC_FS +#include +#endif struct poll_table_struct; struct pipe_inode_info; @@ -135,6 +138,7 @@ struct socket_wq { * @file: File back pointer for gc * @sk: internal networking protocol agnostic socket representation * @wq: wait queue for several uses + * @proc_sockfs_list: list head to link this socket to /proc/net/sockfs */ struct socket { socket_statestate; @@ -150,6 +154,10 @@ struct socket { struct file *file; struct sock *sk; const struct proto_ops *ops; + +#ifdef CONFIG_PROC_FS + struct list_headproc_sockfs_list; +#endif }; struct vm_area_struct; diff --git a/include/net/sock.h b/include/net/sock.h index 72132ae..af37a1e 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -955,6 +955,9 @@ struct proto { void(*destroy_cgroup)(struct mem_cgroup *memcg); struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); #endif + /* Set non-zero value if this protocol manages its + own /proc/net/PROTOCOL entry and the entry has inode column. */ +int has_own_proc_entry; }; /* diff --git a/net/socket.c b/net/socket.c index dfe5b66..5f4f228 100644 --- a/net/socket.c +++ b/net/socket.c @@ -104,6 +104,7 @@ #include #include #include +#include static int sock_no_open(struct inode *irrelevant, struct file *dontcare); static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, @@ -127,6 +128,10 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); +static int proc_sockfs_init(void); +static void proc_sockfs_add(struct socket *sock); +static void proc_sockfs_remove(struct socket *sock); + /* * Socket files have a set of 'special' operations as well as the generic file ones. These don't appear * in the operation structures but are done directly via the socketcall() multiplexor. @@ -259,6 +26
[PATCH v2 09/15] netlink: declaring netlink protocols has its own proc entry
Declaring netlink protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/netlink/af_netlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 5463969..9094be5 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -410,6 +410,7 @@ static struct proto netlink_proto = { .name = "NETLINK", .owner= THIS_MODULE, .obj_size = sizeof(struct netlink_sock), + .has_own_proc_entry= 1, }; static int __netlink_create(struct net *net, struct socket *sock, -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 12/15] ipv6: declaring udplitev6 protocols has its own proc entry
Declaring udplitev6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/udplite.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 1d08e21..9013897 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c @@ -57,6 +57,7 @@ struct proto udplitev6_prot = { .compat_getsockopt = compat_udpv6_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, + .has_own_proc_entry= 1, }; static struct inet_protosw udplite6_protosw = { -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 15/15] ipx: declaring ipx protocols has its own proc entry
Declaring ipx protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipx/af_ipx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index dfd6faa..14be087 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1345,6 +1345,7 @@ static struct proto ipx_proto = { .name = "IPX", .owner= THIS_MODULE, .obj_size = sizeof(struct ipx_sock), + .has_own_proc_entry= 1, }; static int ipx_create(struct net *net, struct socket *sock, int protocol, -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 04/15] ipv4: declaring udplite protocols has its own proc entry
Declaring udplite protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/udplite.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index 2c46acd..14c9dec 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -62,6 +62,7 @@ struct proto udplite_prot = { .compat_getsockopt = compat_udp_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, + .has_own_proc_entry= 1, }; EXPORT_SYMBOL(udplite_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 10/15] ipv6: declaring tcpv6 protocols has its own proc entry
Declaring tcpv6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/tcp_ipv6.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index aa41b0e..741cb3b 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -2017,6 +2017,7 @@ struct proto tcpv6_prot = { #ifdef CONFIG_MEMCG_KMEM .proto_cgroup = tcp_proto_cgroup, #endif + .has_own_proc_entry= 1, }; static const struct inet6_protocol tcpv6_protocol = { -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 06/15] ipv4: declaring tcp protocols has its own proc entry
Declaring tcp protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/tcp_ipv4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index c660d2c..6f36929 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2635,6 +2635,7 @@ struct proto tcp_prot = { .destroy_cgroup = tcp_destroy_cgroup, .proto_cgroup = tcp_proto_cgroup, #endif + .has_own_proc_entry= 1, }; EXPORT_SYMBOL(tcp_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 07/15] packet: declaring packet protocols has its own proc entry
Declaring packet protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/packet/af_packet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ceaca7c..6a0e47c 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2564,6 +2564,7 @@ static struct proto packet_proto = { .name = "PACKET", .owner= THIS_MODULE, .obj_size = sizeof(struct packet_sock), + .has_own_proc_entry= 1, }; /* -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 11/15] ipv6: declaring udpv6 protocols has its own proc entry
Declaring udpv6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/udp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 99d0077..1b28eaf 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1537,6 +1537,7 @@ struct proto udpv6_prot = { .compat_getsockopt = compat_udpv6_getsockopt, #endif .clear_sk = sk_prot_clear_portaddr_nulls, + .has_own_proc_entry= 1, }; static struct inet_protosw udpv6_protosw = { -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 08/15] unix: declaring unix protocols has its own proc entry
Declaring unix protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/unix/af_unix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index e4768c1..7f109e6 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -616,6 +616,7 @@ static struct proto unix_proto = { .name = "UNIX", .owner = THIS_MODULE, .obj_size = sizeof(struct unix_sock), + .has_own_proc_entry= 1, }; /* -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 03/15] ipv4: declaring icmp protocols has its own proc entry
Declaring icmp protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/ping.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 6232d47..c4bb504 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -748,6 +748,7 @@ struct proto ping_prot = { .unhash = ping_v4_unhash, .get_port = ping_v4_get_port, .obj_size = sizeof(struct inet_sock), + .has_own_proc_entry= 1, }; EXPORT_SYMBOL(ping_prot); -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 13/15] ipv6: declaring rawv6 protocols has its own proc entry
Declaring rawv6 protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv6/raw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index ef0579d..62ac59f 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1226,6 +1226,7 @@ struct proto rawv6_prot = { .compat_getsockopt = compat_rawv6_getsockopt, .compat_ioctl = compat_rawv6_ioctl, #endif + .has_own_proc_entry= 1, }; #ifdef CONFIG_PROC_FS -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 05/15] ipv4: declaring raw protocols has its own proc entry
Declaring raw protocols has its own proc entry. Signed-off-by: Masatake YAMATO --- net/ipv4/raw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index ff0f071..3980a4a 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -901,6 +901,7 @@ struct proto raw_prot = { .compat_getsockopt = compat_raw_getsockopt, .compat_ioctl = compat_raw_ioctl, #endif + .has_own_proc_entry= 1, }; #ifdef CONFIG_PROC_FS -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 01/15] net: proc entry showing inodes on sockfs and their types
> > Sorry, you cannot do this. > > You are adding a new lock and insert into a global list for > pretty much every socket created, that will destroy performance. I think there are no serious performance penalty in generally use. Most frequently used types of sockets like tcp, udp, and unix are not stored to the global list and don't touch the new lock at all. Please, look at has_own_proc_entry in struct proto. > You also cannnot add new fields to socket listing procfs files, > it will break existing application which depend upon the existing > exact layout of those fields. Is there any strcut which can be extended? Extending struct sock is o.k.? Masatake YAMATO -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] libiscsi: avoid unnecessary multiple NULL assignments
In iscsi_free_task, NULL is assigned to task->sc twice: before and after kfifo_in invocatoin. Allocating and freeing iscsi_task are guarded with session->lock, so multiple NULL assignments cause no trouble. But people reading the source code may be confused. The second NULL assignment comes from commit: 3e5c28ad0391389959ccae81c938c7533efb3490 It seems that the line after kfifo_in invocation was introduced accidentally. Signed-off-by: Masatake YAMATO --- drivers/scsi/libiscsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 82c3fd4..7aacf3a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -500,21 +500,20 @@ static void iscsi_free_task(struct iscsi_task *task) task->sc = NULL; /* * login task is preallocated so do not free */ if (conn->login_task == task) return; kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*)); if (sc) { - task->sc = NULL; /* SCSI eh reuses commands to verify us */ sc->SCp.ptr = NULL; /* * queue command may call this to free the task, so * it will decide how to return sc to scsi-ml. */ if (oldstate != ISCSI_TASK_REQUEUE_SCSIQ) sc->scsi_done(sc); } } -- 1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] be2iscsi: cleanup format strings using literal string concatenations
In format strings for printk in be2iscsi, literal c string concatenations are used widely. However, the log output is a bit difficult to read because whitespaces are missed in the literal c strings like: SE_DEBUG(DBG_LVL_1, "CQ Error %d, reset" "received/sent on CID 0x%x...\n", You will see "CQ Error 0x resetreceived/sent on CID ..." and wonder what is "resetreceived". This patch cleanup these log messages: - inserting a white space between c string concatenations, - inserting a white space after punctuation, and - inserting white spaces before/after hypen. Signed-off-by: Masatake YAMATO --- drivers/scsi/be2iscsi/be_cmds.c | 4 +-- drivers/scsi/be2iscsi/be_iscsi.c | 10 +++--- drivers/scsi/be2iscsi/be_main.c | 70 drivers/scsi/be2iscsi/be_mgmt.c | 2 +- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c index d2e9e93..d117e7a 100644 --- a/drivers/scsi/be2iscsi/be_cmds.c +++ b/drivers/scsi/be2iscsi/be_cmds.c @@ -93,7 +93,7 @@ int be_chk_reset_complete(struct beiscsi_hba *phba) } if ((status & 0x8000) || (!num_loop)) { - printk(KERN_ERR "Failed in be_chk_reset_complete" + printk(KERN_ERR "Failed in be_chk_reset_complete " "status = 0x%x\n", status); return -EIO; } @@ -245,7 +245,7 @@ void beiscsi_async_link_state_process(struct beiscsi_hba *phba, evt->physical_port); break; default: - SE_DEBUG(DBG_LVL_1, "Unexpected Async Notification %d on" + SE_DEBUG(DBG_LVL_1, "Unexpected Async Notification %d on " "Physical Port %d\n", evt->port_link_status, evt->physical_port); diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 43f3503..15270dd 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c @@ -60,8 +60,8 @@ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, phba = beiscsi_ep->phba; shost = phba->shost; if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { - shost_printk(KERN_ERR, shost, "Cannot handle %d cmds." -"Max cmds per session supported is %d. Using %d. " + shost_printk(KERN_ERR, shost, "Cannot handle %d cmds. " +"Max cmds per session supported is %d. Using %d." "\n", cmds_max, beiscsi_ep->phba->params.wrbs_per_cxn, beiscsi_ep->phba->params.wrbs_per_cxn); @@ -123,7 +123,7 @@ beiscsi_conn_create(struct iscsi_cls_session *cls_session, u32 cid) struct iscsi_session *sess; struct beiscsi_session *beiscsi_sess; - SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_create ,cid" + SE_DEBUG(DBG_LVL_8, "In beiscsi_conn_create, cid " "from iscsi layer=%d\n", cid); shost = iscsi_session_to_shost(cls_session); phba = iscsi_host_priv(shost); @@ -404,7 +404,7 @@ int be2iscsi_iface_set_param(struct Scsi_Host *shost, * BE2ISCSI only supports 1 interface */ if (iface_param->iface_num) { - shost_printk(KERN_ERR, shost, "Invalid iface_num %d." + shost_printk(KERN_ERR, shost, "Invalid iface_num %d. " "Only iface_num 0 is supported.\n", iface_param->iface_num); return -EINVAL; @@ -833,7 +833,7 @@ int beiscsi_conn_start(struct iscsi_cls_conn *cls_conn) memset(¶ms, 0, sizeof(struct beiscsi_offload_params)); beiscsi_ep = beiscsi_conn->ep; if (!beiscsi_ep) - SE_DEBUG(DBG_LVL_1, "In beiscsi_conn_start , no beiscsi_ep\n"); + SE_DEBUG(DBG_LVL_1, "In beiscsi_conn_start, no beiscsi_ep\n"); beiscsi_conn->login_in_progress = 0; beiscsi_set_params_for_offld(beiscsi_conn, ¶ms); diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 0b1d99c..92e534b 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -113,7 +113,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc) &nonemb_cmd.dma); if (nonemb_cmd.va == NULL) { SE_DEBUG(DBG_LVL_1, -"Failed to alloc
Re: [PATCH v3 1/8] bluetooth: /proc/net/ entries for bluetooth protocols
(I have got no reply since 11th Jul. So I resend this mail here. Please, review this patch and merge it if no problem.) (The patch sets are rebased to bluetooth-next. Unnecessary white spaces are trimmed.) lsof command can tell the type of socket processes are using. Internal lsof uses inode numbers on socket fs to resolve the type of sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides such inode information. Unfortunately bluetooth related protocols don't provide such inode information. This patch series introduces /proc/net files for the protocols. This patch against af_bluetooth.c provides facility to the implementation of protocols. This patch extends bt_sock_list and introduces two exported function bt_procfs_init, bt_procfs_cleanup. The type bt_sock_list is already used in some of implementation of protocols. bt_procfs_init prepare seq_operations which converts protocol own bt_sock_list data to protocol own proc entry when the entry is accessed. What I, lsof user, need is just inode number of bluetooth socket. However, people may want more information. The bt_procfs_init takes a function pointer for customizing the show handler of seq_operations. Signed-off-by: Masatake YAMATO --- include/net/bluetooth/bluetooth.h | 10 +++ net/bluetooth/af_bluetooth.c | 136 + 2 files changed, 146 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 565d4be..ede0369 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -27,6 +27,7 @@ #include #include +#include #ifndef AF_BLUETOOTH #define AF_BLUETOOTH 31 @@ -202,6 +203,10 @@ enum { struct bt_sock_list { struct hlist_head head; rwlock_t lock; +#ifdef CONFIG_PROC_FS +struct file_operations fops; +int (* custom_seq_show)(struct seq_file *, void *); +#endif }; int bt_sock_register(int proto, const struct net_proto_family *ops); @@ -292,6 +297,11 @@ extern void hci_sock_cleanup(void); extern int bt_sysfs_init(void); extern void bt_sysfs_cleanup(void); +extern int bt_procfs_init(struct module* module, struct net *net, const char *name, + struct bt_sock_list* sk_list, + int (* seq_show)(struct seq_file *, void *)); +extern void bt_procfs_cleanup(struct net *net, const char *name); + extern struct dentry *bt_debugfs; int l2cap_init(void); diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index f7db579..269fc3d 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -532,6 +532,142 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) } EXPORT_SYMBOL(bt_sock_wait_state); +#ifdef CONFIG_PROC_FS +struct bt_seq_state { + struct bt_sock_list *l; +}; + +static void *bt_seq_start(struct seq_file *seq, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_lock(&l->lock); + return seq_hlist_start_head(&l->head, *pos); +} + +static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + return seq_hlist_next(v, &l->head, pos); +} + +static void bt_seq_stop(struct seq_file *seq, void *v) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_unlock(&l->lock); +} + +static int bt_seq_show(struct seq_file *seq, void *v) +{ + struct sock *sk; + struct bt_sock *bt; + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + bdaddr_t src_baswapped, dst_baswapped; + + if (v == SEQ_START_TOKEN) { + seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); + + if (l->custom_seq_show) { + seq_putc(seq, ' '); + l->custom_seq_show(seq, v); + } + + seq_putc(seq, '\n'); + } else { + sk = sk_entry(v); + bt = bt_sk(sk); + baswap(&src_baswapped, &bt->src); + baswap(&dst_baswapped, &bt->dst); + + seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu", + sk, + atomic_read(&sk->sk_refcnt), + sk_rmem_alloc_get(sk), + sk_wmem_alloc_get(sk), + sock_i_uid(sk), + sock_i_ino(sk), + &src_baswapped, + &dst_baswapped, + bt->parent? sock_i_ino(bt->parent): 0LU); + + if (l->custom_seq_show) {
[PATCH v5 1/8] Bluetooth: /proc/net/ entries for bluetooth protocols
lsof command can tell the type of socket processes are using. Internal lsof uses inode numbers on socket fs to resolve the type of sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides such inode information. Unfortunately bluetooth related protocols don't provide such inode information. This patch series introduces /proc/net files for the protocols. This patch against af_bluetooth.c provides facility to the implementation of protocols. This patch extends bt_sock_list and introduces two exported function bt_procfs_init, bt_procfs_cleanup. The type bt_sock_list is already used in some of implementation of protocols. bt_procfs_init prepare seq_operations which converts protocol own bt_sock_list data to protocol own proc entry when the entry is accessed. What I, lsof user, need is just inode number of bluetooth socket. However, people may want more information. The bt_procfs_init takes a function pointer for customizing the show handler of seq_operations. In v4 patch, __acquires and __releases attributes are added to suppress sparse warning. Suggested by Andrei Emeltchenko. In v5 patch, linux/proc_fs.h is included to use PDE. Build error is reported by Fengguang Wu. Signed-off-by: Masatake YAMATO --- include/net/bluetooth/bluetooth.h | 10 +++ net/bluetooth/af_bluetooth.c | 139 + 2 files changed, 149 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 565d4be..ede0369 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -27,6 +27,7 @@ #include #include +#include #ifndef AF_BLUETOOTH #define AF_BLUETOOTH 31 @@ -202,6 +203,10 @@ enum { struct bt_sock_list { struct hlist_head head; rwlock_t lock; +#ifdef CONFIG_PROC_FS +struct file_operations fops; +int (* custom_seq_show)(struct seq_file *, void *); +#endif }; int bt_sock_register(int proto, const struct net_proto_family *ops); @@ -292,6 +297,11 @@ extern void hci_sock_cleanup(void); extern int bt_sysfs_init(void); extern void bt_sysfs_cleanup(void); +extern int bt_procfs_init(struct module* module, struct net *net, const char *name, + struct bt_sock_list* sk_list, + int (* seq_show)(struct seq_file *, void *)); +extern void bt_procfs_cleanup(struct net *net, const char *name); + extern struct dentry *bt_debugfs; int l2cap_init(void); diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index f7db579..1a03c81 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -28,6 +28,7 @@ #include #include +#include #define VERSION "2.16" @@ -532,6 +533,144 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) } EXPORT_SYMBOL(bt_sock_wait_state); +#ifdef CONFIG_PROC_FS +struct bt_seq_state { + struct bt_sock_list *l; +}; + +static void *bt_seq_start(struct seq_file *seq, loff_t *pos) + __acquires(seq->private->l->lock) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_lock(&l->lock); + return seq_hlist_start_head(&l->head, *pos); +} + +static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + return seq_hlist_next(v, &l->head, pos); +} + +static void bt_seq_stop(struct seq_file *seq, void *v) + __releases(seq->private->l->lock) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_unlock(&l->lock); +} + +static int bt_seq_show(struct seq_file *seq, void *v) +{ + struct sock *sk; + struct bt_sock *bt; + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + bdaddr_t src_baswapped, dst_baswapped; + + if (v == SEQ_START_TOKEN) { + seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); + + if (l->custom_seq_show) { + seq_putc(seq, ' '); + l->custom_seq_show(seq, v); + } + + seq_putc(seq, '\n'); + } else { + sk = sk_entry(v); + bt = bt_sk(sk); + baswap(&src_baswapped, &bt->src); + baswap(&dst_baswapped, &bt->dst); + + seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu", + sk, + atomic_read(&sk->sk_refcnt), + sk_rmem_alloc_get(sk), + sk_wmem_alloc_get(sk), + sock_i_uid(sk), + sock_i_ino(sk), +
[PATCH v5 2/8] Bluetooth: Added /proc/net/bnep via bt_procfs_init()
Added /proc/net/bnep via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/bnep/sock.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index 5e5f5b4..5b6cc0b 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c @@ -29,6 +29,10 @@ #include "bnep.h" +static struct bt_sock_list bnep_sk_list = { + .lock = __RW_LOCK_UNLOCKED(bnep_sk_list.lock) +}; + static int bnep_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -38,6 +42,8 @@ static int bnep_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&bnep_sk_list, sk); + sock_orphan(sk); sock_put(sk); return 0; @@ -204,6 +210,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_protocol = protocol; sk->sk_state= BT_OPEN; + bt_sock_link(&bnep_sk_list, sk); return 0; } @@ -222,19 +229,30 @@ int __init bnep_sock_init(void) return err; err = bt_sock_register(BTPROTO_BNEP, &bnep_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("Can't register BNEP socket"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "bnep", &bnep_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create BNEP proc file"); + bt_sock_unregister(BTPROTO_BNEP); + goto error; + } + + BT_INFO("BNEP socket layer initialized"); return 0; error: - BT_ERR("Can't register BNEP socket"); proto_unregister(&bnep_proto); return err; } void __exit bnep_sock_cleanup(void) { + bt_procfs_cleanup(&init_net, "bnep"); if (bt_sock_unregister(BTPROTO_BNEP) < 0) BT_ERR("Can't unregister BNEP socket"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 3/8] Bluetooth: Added /proc/net/cmtp via bt_procfs_init()
Added /proc/net/cmtp via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/cmtp/sock.c | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index 311668d..d5cacef 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c @@ -42,6 +42,10 @@ #include "cmtp.h" +static struct bt_sock_list cmtp_sk_list = { + .lock = __RW_LOCK_UNLOCKED(cmtp_sk_list.lock) +}; + static int cmtp_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -51,6 +55,8 @@ static int cmtp_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&cmtp_sk_list, sk); + sock_orphan(sk); sock_put(sk); @@ -214,6 +220,8 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_protocol = protocol; sk->sk_state= BT_OPEN; + bt_sock_link(&cmtp_sk_list, sk); + return 0; } @@ -232,19 +240,30 @@ int cmtp_init_sockets(void) return err; err = bt_sock_register(BTPROTO_CMTP, &cmtp_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("Can't register CMTP socket"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "cmtp", &cmtp_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create CMTP proc file"); + bt_sock_unregister(BTPROTO_HIDP); + goto error; + } + + BT_INFO("CMTP socket layer initialized"); return 0; error: - BT_ERR("Can't register CMTP socket"); proto_unregister(&cmtp_proto); return err; } void cmtp_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "cmtp"); if (bt_sock_unregister(BTPROTO_CMTP) < 0) BT_ERR("Can't unregister CMTP socket"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 4/8] Bluetooth: Added /proc/net/hci via bt_procfs_init()
Added /proc/net/hci via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/hci_sock.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index a7f04de..7c3d6c7 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -1100,21 +1100,30 @@ int __init hci_sock_init(void) return err; err = bt_sock_register(BTPROTO_HCI, &hci_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("HCI socket registration failed"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "hci", &hci_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create HCI proc file"); + bt_sock_unregister(BTPROTO_HCI); + goto error; + } BT_INFO("HCI socket layer initialized"); return 0; error: - BT_ERR("HCI socket registration failed"); proto_unregister(&hci_sk_proto); return err; } void hci_sock_cleanup(void) { + bt_procfs_cleanup(&init_net, "hci"); if (bt_sock_unregister(BTPROTO_HCI) < 0) BT_ERR("HCI socket unregistration failed"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 5/8] Bluetooth: Added /proc/net/hidp via bt_procfs_init()
Added /proc/net/hidp via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/hidp/sock.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 18b3f68..eca3889 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -25,6 +25,10 @@ #include "hidp.h" +static struct bt_sock_list hidp_sk_list = { + .lock = __RW_LOCK_UNLOCKED(hidp_sk_list.lock) +}; + static int hidp_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -34,6 +38,8 @@ static int hidp_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&hidp_sk_list, sk); + sock_orphan(sk); sock_put(sk); @@ -253,6 +259,8 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_protocol = protocol; sk->sk_state= BT_OPEN; + bt_sock_link(&hidp_sk_list, sk); + return 0; } @@ -271,8 +279,19 @@ int __init hidp_init_sockets(void) return err; err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("Can't register HIDP socket"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "hidp", &hidp_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create HIDP proc file"); + bt_sock_unregister(BTPROTO_HIDP); + goto error; + } + + BT_INFO("HIDP socket layer initialized"); return 0; @@ -284,6 +303,7 @@ error: void __exit hidp_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "hidp"); if (bt_sock_unregister(BTPROTO_HIDP) < 0) BT_ERR("Can't unregister HIDP socket"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 6/8] Bluetooth: Added /proc/net/l2cap via bt_procfs_init()
Added /proc/net/l2cap via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/l2cap_sock.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a4bb27e..04bd647 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -34,6 +34,10 @@ #include #include +static struct bt_sock_list l2cap_sk_list = { + .lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock) +}; + static const struct proto_ops l2cap_sock_ops; static void l2cap_sock_init(struct sock *sk, struct sock *parent); static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); @@ -886,6 +890,8 @@ static int l2cap_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&l2cap_sk_list, sk); + err = l2cap_sock_shutdown(sock, 2); sock_orphan(sk); @@ -1210,6 +1216,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, return -ENOMEM; l2cap_sock_init(sk, NULL); + bt_sock_link(&l2cap_sk_list, sk); return 0; } @@ -1248,21 +1255,30 @@ int __init l2cap_init_sockets(void) return err; err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("L2CAP socket registration failed"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create L2CAP proc file"); + bt_sock_unregister(BTPROTO_L2CAP); + goto error; + } BT_INFO("L2CAP socket layer initialized"); return 0; error: - BT_ERR("L2CAP socket registration failed"); proto_unregister(&l2cap_proto); return err; } void l2cap_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "l2cap"); if (bt_sock_unregister(BTPROTO_L2CAP) < 0) BT_ERR("L2CAP socket unregistration failed"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 7/8] Bluetooth: Added /proc/net/rfcomm via bt_procfs_init()
Added /proc/net/rfcomm via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/rfcomm/sock.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 7e1e596..260821a 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -1033,8 +1033,17 @@ int __init rfcomm_init_sockets(void) return err; err = bt_sock_register(BTPROTO_RFCOMM, &rfcomm_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("RFCOMM socket layer registration failed"); + goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "rfcomm", &rfcomm_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create RFCOMM proc file"); + bt_sock_unregister(BTPROTO_RFCOMM); goto error; + } if (bt_debugfs) { rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444, @@ -1048,13 +1057,14 @@ int __init rfcomm_init_sockets(void) return 0; error: - BT_ERR("RFCOMM socket layer registration failed"); proto_unregister(&rfcomm_proto); return err; } void __exit rfcomm_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "rfcomm"); + debugfs_remove(rfcomm_sock_debugfs); if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5 8/8] Added /proc/net/sco via bt_procfs_init()
Added /proc/net/sco via bt_procfs_init(). Signed-off-by: Masatake YAMATO --- net/bluetooth/sco.c |9 + 1 file changed, 9 insertions(+) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 0ef5a78..caa109d 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -1023,6 +1023,13 @@ int __init sco_init(void) goto error; } + err = bt_procfs_init(THIS_MODULE, &init_net, "sco", &sco_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create SCO proc file"); + bt_sock_unregister(BTPROTO_SCO); + goto error; + } + if (bt_debugfs) { sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs, NULL, &sco_debugfs_fops); @@ -1041,6 +1048,8 @@ error: void __exit sco_exit(void) { + bt_procfs_cleanup(&init_net, "sco"); + debugfs_remove(sco_debugfs); if (bt_sock_unregister(BTPROTO_SCO) < 0) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 1/8] bluetooth: /proc/net/ entries for bluetooth protocols
(The patch sets are rebased to bluetooth-next. Unnecessary white spaces are trimmed.) lsof command can tell the type of socket processes are using. Internal lsof uses inode numbers on socket fs to resolve the type of sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides such inode information. Unfortunately bluetooth related protocols don't provide such inode information. This patch series introduces /proc/net files for the protocols. This patch against af_bluetooth.c provides facility to the implementation of protocols. This patch extends bt_sock_list and introduces two exported function bt_procfs_init, bt_procfs_cleanup. The type bt_sock_list is already used in some of implementation of protocols. bt_procfs_init prepare seq_operations which converts protocol own bt_sock_list data to protocol own proc entry when the entry is accessed. What I, lsof user, need is just inode number of bluetooth socket. However, people may want more information. The bt_procfs_init takes a function pointer for customizing the show handler of seq_operations. Signed-off-by: Masatake YAMATO --- include/net/bluetooth/bluetooth.h | 10 +++ net/bluetooth/af_bluetooth.c | 136 + 2 files changed, 146 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 565d4be..ede0369 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -27,6 +27,7 @@ #include #include +#include #ifndef AF_BLUETOOTH #define AF_BLUETOOTH 31 @@ -202,6 +203,10 @@ enum { struct bt_sock_list { struct hlist_head head; rwlock_t lock; +#ifdef CONFIG_PROC_FS +struct file_operations fops; +int (* custom_seq_show)(struct seq_file *, void *); +#endif }; int bt_sock_register(int proto, const struct net_proto_family *ops); @@ -292,6 +297,11 @@ extern void hci_sock_cleanup(void); extern int bt_sysfs_init(void); extern void bt_sysfs_cleanup(void); +extern int bt_procfs_init(struct module* module, struct net *net, const char *name, + struct bt_sock_list* sk_list, + int (* seq_show)(struct seq_file *, void *)); +extern void bt_procfs_cleanup(struct net *net, const char *name); + extern struct dentry *bt_debugfs; int l2cap_init(void); diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index f7db579..269fc3d 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -532,6 +532,142 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) } EXPORT_SYMBOL(bt_sock_wait_state); +#ifdef CONFIG_PROC_FS +struct bt_seq_state { + struct bt_sock_list *l; +}; + +static void *bt_seq_start(struct seq_file *seq, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_lock(&l->lock); + return seq_hlist_start_head(&l->head, *pos); +} + +static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + return seq_hlist_next(v, &l->head, pos); +} + +static void bt_seq_stop(struct seq_file *seq, void *v) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_unlock(&l->lock); +} + +static int bt_seq_show(struct seq_file *seq, void *v) +{ + struct sock *sk; + struct bt_sock *bt; + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + bdaddr_t src_baswapped, dst_baswapped; + + if (v == SEQ_START_TOKEN) { + seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); + + if (l->custom_seq_show) { + seq_putc(seq, ' '); + l->custom_seq_show(seq, v); + } + + seq_putc(seq, '\n'); + } else { + sk = sk_entry(v); + bt = bt_sk(sk); + baswap(&src_baswapped, &bt->src); + baswap(&dst_baswapped, &bt->dst); + + seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu", + sk, + atomic_read(&sk->sk_refcnt), + sk_rmem_alloc_get(sk), + sk_wmem_alloc_get(sk), + sock_i_uid(sk), + sock_i_ino(sk), + &src_baswapped, + &dst_baswapped, + bt->parent? sock_i_ino(bt->parent): 0LU); + + if (l->custom_seq_show) { + seq_putc(seq, ' '); + l->custom_seq_show(seq, v); + }
[PATCH v3 2/8] bluetooth: Added /proc/net/bnep via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/bnep/sock.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index 5e5f5b4..5b6cc0b 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c @@ -29,6 +29,10 @@ #include "bnep.h" +static struct bt_sock_list bnep_sk_list = { + .lock = __RW_LOCK_UNLOCKED(bnep_sk_list.lock) +}; + static int bnep_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -38,6 +42,8 @@ static int bnep_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&bnep_sk_list, sk); + sock_orphan(sk); sock_put(sk); return 0; @@ -204,6 +210,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_protocol = protocol; sk->sk_state= BT_OPEN; + bt_sock_link(&bnep_sk_list, sk); return 0; } @@ -222,19 +229,30 @@ int __init bnep_sock_init(void) return err; err = bt_sock_register(BTPROTO_BNEP, &bnep_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("Can't register BNEP socket"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "bnep", &bnep_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create BNEP proc file"); + bt_sock_unregister(BTPROTO_BNEP); + goto error; + } + + BT_INFO("BNEP socket layer initialized"); return 0; error: - BT_ERR("Can't register BNEP socket"); proto_unregister(&bnep_proto); return err; } void __exit bnep_sock_cleanup(void) { + bt_procfs_cleanup(&init_net, "bnep"); if (bt_sock_unregister(BTPROTO_BNEP) < 0) BT_ERR("Can't unregister BNEP socket"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 3/8] bluetooth: Added /proc/net/cmtp via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/cmtp/sock.c | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index 311668d..d5cacef 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c @@ -42,6 +42,10 @@ #include "cmtp.h" +static struct bt_sock_list cmtp_sk_list = { + .lock = __RW_LOCK_UNLOCKED(cmtp_sk_list.lock) +}; + static int cmtp_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -51,6 +55,8 @@ static int cmtp_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&cmtp_sk_list, sk); + sock_orphan(sk); sock_put(sk); @@ -214,6 +220,8 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_protocol = protocol; sk->sk_state= BT_OPEN; + bt_sock_link(&cmtp_sk_list, sk); + return 0; } @@ -232,19 +240,30 @@ int cmtp_init_sockets(void) return err; err = bt_sock_register(BTPROTO_CMTP, &cmtp_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("Can't register CMTP socket"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "cmtp", &cmtp_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create CMTP proc file"); + bt_sock_unregister(BTPROTO_HIDP); + goto error; + } + + BT_INFO("CMTP socket layer initialized"); return 0; error: - BT_ERR("Can't register CMTP socket"); proto_unregister(&cmtp_proto); return err; } void cmtp_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "cmtp"); if (bt_sock_unregister(BTPROTO_CMTP) < 0) BT_ERR("Can't unregister CMTP socket"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 4/8] bluetooth: Added /proc/net/hci via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/hci_sock.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index a7f04de..7c3d6c7 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -1100,21 +1100,30 @@ int __init hci_sock_init(void) return err; err = bt_sock_register(BTPROTO_HCI, &hci_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("HCI socket registration failed"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "hci", &hci_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create HCI proc file"); + bt_sock_unregister(BTPROTO_HCI); + goto error; + } BT_INFO("HCI socket layer initialized"); return 0; error: - BT_ERR("HCI socket registration failed"); proto_unregister(&hci_sk_proto); return err; } void hci_sock_cleanup(void) { + bt_procfs_cleanup(&init_net, "hci"); if (bt_sock_unregister(BTPROTO_HCI) < 0) BT_ERR("HCI socket unregistration failed"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 5/8] bluetooth: Added /proc/net/hidp via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/hidp/sock.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 18b3f68..a481f8d 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -25,6 +25,10 @@ #include "hidp.h" +static struct bt_sock_list hidp_sk_list = { + .lock = __RW_LOCK_UNLOCKED(hidp_sk_list.lock) +}; + static int hidp_sock_release(struct socket *sock) { struct sock *sk = sock->sk; @@ -34,6 +38,8 @@ static int hidp_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&hidp_sk_list, sk); + sock_orphan(sk); sock_put(sk); @@ -253,6 +259,8 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, sk->sk_protocol = protocol; sk->sk_state= BT_OPEN; + bt_sock_link(&hidp_sk_list, sk); + return 0; } @@ -271,9 +279,20 @@ int __init hidp_init_sockets(void) return err; err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("Can't register HIDP socket"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "hidp", &hidp_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create HIDP proc file"); + bt_sock_unregister(BTPROTO_HIDP); + goto error; + } + BT_INFO("HIDP socket layer initialized"); + return 0; error: @@ -284,6 +303,7 @@ error: void __exit hidp_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "hidp"); if (bt_sock_unregister(BTPROTO_HIDP) < 0) BT_ERR("Can't unregister HIDP socket"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 6/8] bluetooth: Added /proc/net/l2cap via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/l2cap_sock.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a4bb27e..c9a9f1c 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -34,6 +34,10 @@ #include #include +static struct bt_sock_list l2cap_sk_list = { + .lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock) +}; + static const struct proto_ops l2cap_sock_ops; static void l2cap_sock_init(struct sock *sk, struct sock *parent); static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); @@ -886,6 +890,8 @@ static int l2cap_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&l2cap_sk_list, sk); + err = l2cap_sock_shutdown(sock, 2); sock_orphan(sk); @@ -1210,6 +1216,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, return -ENOMEM; l2cap_sock_init(sk, NULL); + bt_sock_link(&l2cap_sk_list, sk); return 0; } @@ -1248,22 +1255,30 @@ int __init l2cap_init_sockets(void) return err; err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("L2CAP socket registration failed"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create L2CAP proc file"); + bt_sock_unregister(BTPROTO_L2CAP); + goto error; + } BT_INFO("L2CAP socket layer initialized"); return 0; error: - BT_ERR("L2CAP socket registration failed"); proto_unregister(&l2cap_proto); return err; } void l2cap_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "l2cap"); if (bt_sock_unregister(BTPROTO_L2CAP) < 0) BT_ERR("L2CAP socket unregistration failed"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 7/8] bluetooth: Added /proc/net/rfcomm via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/rfcomm/sock.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 7e1e596..260821a 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -1033,8 +1033,17 @@ int __init rfcomm_init_sockets(void) return err; err = bt_sock_register(BTPROTO_RFCOMM, &rfcomm_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("RFCOMM socket layer registration failed"); + goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "rfcomm", &rfcomm_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create RFCOMM proc file"); + bt_sock_unregister(BTPROTO_RFCOMM); goto error; + } if (bt_debugfs) { rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444, @@ -1048,13 +1057,14 @@ int __init rfcomm_init_sockets(void) return 0; error: - BT_ERR("RFCOMM socket layer registration failed"); proto_unregister(&rfcomm_proto); return err; } void __exit rfcomm_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "rfcomm"); + debugfs_remove(rfcomm_sock_debugfs); if (bt_sock_unregister(BTPROTO_RFCOMM) < 0) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 8/8] bluetooth: Added /proc/net/sco via bt_procfs_init()
Signed-off-by: Masatake YAMATO --- net/bluetooth/sco.c |9 + 1 file changed, 9 insertions(+) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 40bbe25..85efd9f 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -1026,6 +1026,13 @@ int __init sco_init(void) goto error; } + err = bt_procfs_init(THIS_MODULE, &init_net, "sco", &sco_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create SCO proc file"); + bt_sock_unregister(BTPROTO_SCO); + goto error; + } + if (bt_debugfs) { sco_debugfs = debugfs_create_file("sco", 0444, bt_debugfs, NULL, &sco_debugfs_fops); @@ -1044,6 +1051,8 @@ error: void __exit sco_exit(void) { + bt_procfs_cleanup(&init_net, "sco"); + debugfs_remove(sco_debugfs); if (bt_sock_unregister(BTPROTO_SCO) < 0) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 6/8] bluetooth: Added /proc/net/l2cap via bt_procfs_init()
Andrei, thank you for taking time. I've rebased again and I applied my patches with git am. They are applied without problem. I've regenerated the patches again and compared the new ones with the older ones. About [PATCH v3 6/8] bluetooth: Added /proc/net/l2cap via bt_procfs_init() One line slided. I've paste the new one to this mail. About [PATCH v3 7/8] bluetooth: Added /proc/net/rfcomm via bt_procfs_init() I cannot find any change between new one and older one. What can I do? Masatake YAMATO >From c56754680ec4005de7586b6afa7155228e0bbd6e Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Thu, 14 Jun 2012 23:52:08 +0900 Subject: [PATCH 6/8] Added /proc/net/l2cap via bt_procfs_init() Signed-off-by: Masatake YAMATO --- net/bluetooth/l2cap_sock.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index a4bb27e..04bd647 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -34,6 +34,10 @@ #include #include +static struct bt_sock_list l2cap_sk_list = { + .lock = __RW_LOCK_UNLOCKED(l2cap_sk_list.lock) +}; + static const struct proto_ops l2cap_sock_ops; static void l2cap_sock_init(struct sock *sk, struct sock *parent); static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); @@ -886,6 +890,8 @@ static int l2cap_sock_release(struct socket *sock) if (!sk) return 0; + bt_sock_unlink(&l2cap_sk_list, sk); + err = l2cap_sock_shutdown(sock, 2); sock_orphan(sk); @@ -1210,6 +1216,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, return -ENOMEM; l2cap_sock_init(sk, NULL); + bt_sock_link(&l2cap_sk_list, sk); return 0; } @@ -1248,21 +1255,30 @@ int __init l2cap_init_sockets(void) return err; err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops); - if (err < 0) + if (err < 0) { + BT_ERR("L2CAP socket registration failed"); goto error; + } + + err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); + if (err < 0) { + BT_ERR("Failed to create L2CAP proc file"); + bt_sock_unregister(BTPROTO_L2CAP); + goto error; + } BT_INFO("L2CAP socket layer initialized"); return 0; error: - BT_ERR("L2CAP socket registration failed"); proto_unregister(&l2cap_proto); return err; } void l2cap_cleanup_sockets(void) { + bt_procfs_cleanup(&init_net, "l2cap"); if (bt_sock_unregister(BTPROTO_L2CAP) < 0) BT_ERR("L2CAP socket unregistration failed"); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 1/8] bluetooth: /proc/net/ entries for bluetooth protocols
Hi, > Hi Masatake, > > On Wed, Jul 11, 2012 at 01:58:31PM +0900, Masatake YAMATO wrote: >> (The patch sets are rebased to bluetooth-next. Unnecessary white >> spaces are trimmed.) >> >> lsof command can tell the type of socket processes are using. >> Internal lsof uses inode numbers on socket fs to resolve the type of >> sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides >> such inode information. >> >> Unfortunately bluetooth related protocols don't provide such inode >> information. This patch series introduces /proc/net files for the protocols. >> >> This patch against af_bluetooth.c provides facility to the implementation >> of protocols. This patch extends bt_sock_list and introduces two exported >> function bt_procfs_init, bt_procfs_cleanup. >> >> The type bt_sock_list is already used in some of implementation of >> protocols. bt_procfs_init prepare seq_operations which converts >> protocol own bt_sock_list data to protocol own proc entry when the >> entry is accessed. >> >> What I, lsof user, need is just inode number of bluetooth >> socket. However, people may want more information. The bt_procfs_init >> takes a function pointer for customizing the show handler of >> seq_operations. > > I've tested the patch and it creates entries in /proc/net Thanks. > BTW: Shall lsof be able to identify l2cap protocol? > > for l2test it prints: "can't identify protocol" No. I'll work on lsof side after the kernel side patches are merged to the main line. Masatake YAMATO > Best regards > Andrei Emeltchenko > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[no subject]
>From 1844089350ec3298978418e75cdfe2bb5062c438 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO , Masatake YAMATO Subject: [PATCH v4 1/8] /proc/net/ entries for bluetooth protocols In-Reply-To: <20120712074200.GA12931@aemeltch-MOBL1> References: <2012072308.GA3044@aemeltch-MOBL1> <20120711.211906.1087916687452547370.yam...@redhat.com> <20120712074200.GA12931@aemeltch-MOBL1> Organization: Red Hat Japan, Inc. X-Mailer: Mew version 6.5 on Emacs 24.0.97 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit (Andrei, [PATCH v4 [2-8]/8] are the same as [PATCH v3 [2-8]/8]. So I send [PATCH v4 1/8] only here. If I should the rest of v4 patches, please, let me know that.) lsof command can tell the type of socket processes are using. Internal lsof uses inode numbers on socket fs to resolve the type of sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides such inode information. Unfortunately bluetooth related protocols don't provide such inode information. This patch series introduces /proc/net files for the protocols. This patch against af_bluetooth.c provides facility to the implementation of protocols. This patch extends bt_sock_list and introduces two exported function bt_procfs_init, bt_procfs_cleanup. The type bt_sock_list is already used in some of implementation of protocols. bt_procfs_init prepare seq_operations which converts protocol own bt_sock_list data to protocol own proc entry when the entry is accessed. What I, lsof user, need is just inode number of bluetooth socket. However, people may want more information. The bt_procfs_init takes a function pointer for customizing the show handler of seq_operations. In v4 patch, __acquires and __releases attributes are added to suppress sparse warning. Suggested by Andrei Emeltchenko. Signed-off-by: Masatake YAMATO --- include/net/bluetooth/bluetooth.h | 10 +++ net/bluetooth/af_bluetooth.c | 138 + 2 files changed, 148 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 565d4be..ede0369 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -27,6 +27,7 @@ #include #include +#include #ifndef AF_BLUETOOTH #define AF_BLUETOOTH 31 @@ -202,6 +203,10 @@ enum { struct bt_sock_list { struct hlist_head head; rwlock_t lock; +#ifdef CONFIG_PROC_FS +struct file_operations fops; +int (* custom_seq_show)(struct seq_file *, void *); +#endif }; int bt_sock_register(int proto, const struct net_proto_family *ops); @@ -292,6 +297,11 @@ extern void hci_sock_cleanup(void); extern int bt_sysfs_init(void); extern void bt_sysfs_cleanup(void); +extern int bt_procfs_init(struct module* module, struct net *net, const char *name, + struct bt_sock_list* sk_list, + int (* seq_show)(struct seq_file *, void *)); +extern void bt_procfs_cleanup(struct net *net, const char *name); + extern struct dentry *bt_debugfs; int l2cap_init(void); diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index f7db579..f76cf2f 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -532,6 +532,144 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) } EXPORT_SYMBOL(bt_sock_wait_state); +#ifdef CONFIG_PROC_FS +struct bt_seq_state { + struct bt_sock_list *l; +}; + +static void *bt_seq_start(struct seq_file *seq, loff_t *pos) + __acquires(seq->private->l->lock) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_lock(&l->lock); + return seq_hlist_start_head(&l->head, *pos); +} + +static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + return seq_hlist_next(v, &l->head, pos); +} + +static void bt_seq_stop(struct seq_file *seq, void *v) + __releases(seq->private->l->lock) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_unlock(&l->lock); +} + +static int bt_seq_show(struct seq_file *seq, void *v) +{ + struct sock *sk; + struct bt_sock *bt; + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + bdaddr_t src_baswapped, dst_baswapped; + + if (v == SEQ_START_TOKEN) { + seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); + + if (l->custom_seq_show) { + seq_putc(seq, ' '); + l->custom_seq_show(seq, v); + } + + seq_putc(seq, '\n&
[RESEND2 PATCH] libiscsi: avoid unnecessary multiple NULL assignments
In iscsi_free_task, NULL is assigned to task->sc twice: before and after kfifo_in invocatoin. Allocating and freeing iscsi_task are guarded with session->lock, so multiple NULL assignments cause no trouble. But people reading the source code may be confused. The second NULL assignment comes from commit: 3e5c28ad0391389959ccae81c938c7533efb3490 It seems that the line after kfifo_in invocation was introduced accidentally. Signed-off-by: Masatake YAMATO Reviewed-by: Mike Christie --- drivers/scsi/libiscsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 82c3fd4..7aacf3a 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -507,7 +507,6 @@ static void iscsi_free_task(struct iscsi_task *task) kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*)); if (sc) { - task->sc = NULL; /* SCSI eh reuses commands to verify us */ sc->SCp.ptr = NULL; /* -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Avoid to use kmalloc in usb/core/message.c
In some functions in drivers/usb/core/message.c kmalloc is used to allocate fix size of memory chunks; and the chunks is freed at the end of each functions. The sizes are not so large: 8(struct usb_ctrlrequest), 18(struct usb_device_descriptor), and 2(u16) bytes. I wonder why the invocations of kmalloc are needed in these functions. Following patch is for avoiding invocations of kmalloc. Instead stacks are used. The patch is generated by co-diff against rsync://kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> Index: drivers/usb/core/message.c === --- 6f51e67e4a433ee0ff866a6ac18a4bce798fe0c7/drivers/usb/core/message.c (mode:100644) +++ uncommitted/drivers/usb/core/message.c (mode:100644) @@ -142,11 +142,9 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout) { - struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); + struct usb_ctrlrequest dr_rec; + struct usb_ctrlrequest *dr = &dr_rec; int ret; - - if (!dr) - return -ENOMEM; dr->bRequestType= requesttype; dr->bRequest = request; @@ -158,7 +156,6 @@ ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); - kfree(dr); return ret; } @@ -794,19 +791,17 @@ */ int usb_get_device_descriptor(struct usb_device *dev, unsigned int size) { + struct usb_device_descriptor desc_rec; struct usb_device_descriptor *desc; int ret; if (size > sizeof(*desc)) return -EINVAL; - desc = kmalloc(sizeof(*desc), GFP_NOIO); - if (!desc) - return -ENOMEM; + desc = &desc_rec; ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); if (ret >= 0) memcpy(&dev->descriptor, desc, size); - kfree(desc); return ret; } @@ -835,17 +830,13 @@ int usb_get_status(struct usb_device *dev, int type, int target, void *data) { int ret; - u16 *status = kmalloc(sizeof(*status), GFP_KERNEL); - - if (!status) - return -ENOMEM; + u16 status; ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, status, - sizeof(*status), USB_CTRL_GET_TIMEOUT); + USB_REQ_GET_STATUS, USB_DIR_IN | type, 0, target, &status, + sizeof(status), USB_CTRL_GET_TIMEOUT); - *(u16 *)data = *status; - kfree(status); + *(u16 *)data = status; return ret; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] checking ADVICE of fadvice64_64 even if get_xip_page is given
Hi, I've written some test programs in ltp project. During writing I met an problem which I cannot solve in user land. So I wrote a patch for linux kernel. Please, include this patch if acceptable. The test program tests the 4th parameter of fadvise64_64: long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice); My test case calls fadvise64_64 with invalid advice value and checks errno is set to EINVAL. About the advice parameter man page says: ... Permissible values for advice include: POSIX_FADV_NORMAL ... POSIX_FADV_SEQUENTIAL ... POSIX_FADV_RANDOM ... POSIX_FADV_NOREUSE ... POSIX_FADV_WILLNEED ... POSIX_FADV_DONTNEED ... ERRORS ... EINVAL An invalid value was specified for advice. However, I got a bug report that the system call invocations in my test case returned 0 unexpectedly. I've inspected the kernel code: asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) { struct file *file = fget(fd); struct address_space *mapping; struct backing_dev_info *bdi; loff_t endbyte; /* inclusive */ pgoff_t start_index; pgoff_t end_index; unsigned long nrpages; int ret = 0; if (!file) return -EBADF; if (S_ISFIFO(file->f_path.dentry->d_inode->i_mode)) { ret = -ESPIPE; goto out; } mapping = file->f_mapping; if (!mapping || len < 0) { ret = -EINVAL; goto out; } if (mapping->a_ops->get_xip_page) /* no bad return value, but ignore advice */ goto out; ... out: fput(file); return ret; } I found the advice parameter is just ignored in the case mapping->a_ops->get_xip_page is given. This behavior is different from what is written on the man page. Is this o.k.? get_xip_page is given if CONFIG_EXT2_FS_XIP is true. Anyway I cannot find the easy way to detect get_xip_page field is given or CONFIG_EXT2_FS_XIP is true from the user space. I propose the following patch which checks the advice parameter even if get_xip_page is given. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/mm/fadvise.c b/mm/fadvise.c index 0df4c89..3c0f1e9 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -49,9 +49,21 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) goto out; } - if (mapping->a_ops->get_xip_page) - /* no bad return value, but ignore advice */ + if (mapping->a_ops->get_xip_page) { + switch (advice) { + case POSIX_FADV_NORMAL: + case POSIX_FADV_RANDOM: + case POSIX_FADV_SEQUENTIAL: + case POSIX_FADV_WILLNEED: + case POSIX_FADV_NOREUSE: + case POSIX_FADV_DONTNEED: + /* no bad return value, but ignore advice */ + break; + default: + ret = -EINVAL; + } goto out; + } /* Careful about overflows. Len == 0 means "as much as possible" */ endbyte = offset + len; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch] remove description for non existing parameter in generic_set_mtrr
`do_safe' parameter is not in generic_set_mtrr but explained. Maybe someone forgot removing. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 992f08d..e0c0676 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c @@ -417,8 +417,6 @@ static void generic_set_mtrr(unsigned int reg, unsigned long base, The base address of the region. The size of the region. If this is 0 the region is disabled. The type of the region. - If TRUE, do the change safely. If FALSE, safety measures should -be done externally. [RETURNS] Nothing. */ { - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch-resend] Show ioremap and vmap in /proc/meminfo
Hi, The patch I posted has not got any response. Do you think ioremap and vmap information in /proc/meminfo is not useful? or are you just busy? Hi, For long time I've been thought the following equation is correct: The "MemUsage" is about "Active + Inactive + Slab + PageTables + VmallocUsed" in /proc/meminfo. (I'm not only the person. See https://bugzilla.redhat.com/show_bug.cgi?id=243657.) However, some VmallocUsed doesn't really consume MemUsage: ioremap pages and vmap pages consume just virtual address spaces. It is a bit helpful for people who want to understand kernel memory usage to show the number of ioremap and vmap pages in /proc/meminfo. The following patch adds entries for ioremap and vmap to /proc/meminfo. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/fs/proc/internal.h b/fs/proc/internal.h index b215c35..b888c59 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -19,6 +19,8 @@ static inline void proc_sys_init(void) { } struct vmalloc_info { unsigned long used; + unsigned long used_as_ioremap; + unsigned long used_as_vmap; unsigned long largest_chunk; }; @@ -31,6 +33,8 @@ extern void get_vmalloc_info(struct vmalloc_info *vmi); #define get_vmalloc_info(vmi) \ do { \ (vmi)->used = 0;\ + (vmi)->used_as_ioremap = 0; \ + (vmi)->used_as_vmap = 0;\ (vmi)->largest_chunk = 0; \ } while(0) diff --git a/fs/proc/mmu.c b/fs/proc/mmu.c index 25d2d9c..5297df2 100644 --- a/fs/proc/mmu.c +++ b/fs/proc/mmu.c @@ -38,7 +38,9 @@ void get_vmalloc_info(struct vmalloc_info *vmi) unsigned long prev_end; vmi->used = 0; - + vmi->used_as_ioremap = 0; + vmi->used_as_vmap = 0; + if (!vmlist) { vmi->largest_chunk = VMALLOC_TOTAL; } @@ -51,6 +53,8 @@ void get_vmalloc_info(struct vmalloc_info *vmi) for (vma = vmlist; vma; vma = vma->next) { unsigned long addr = (unsigned long) vma->addr; + unsigned long flags; + unsigned long size; /* * Some archs keep another range for modules in vmlist @@ -59,8 +63,15 @@ void get_vmalloc_info(struct vmalloc_info *vmi) continue; if (addr >= VMALLOC_END) break; - - vmi->used += vma->size; + + size = vma->size; + flags = vma->flags; + + vmi->used += size; + if (flags & VM_IOREMAP) + vmi->used_as_ioremap += size; + if (flags & VM_MAP) + vmi->used_as_vmap += size; free_area_size = addr - prev_end; if (vmi->largest_chunk < free_area_size) diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index bee251c..d784c85 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -176,6 +176,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, "Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n" "VmallocUsed: %8lu kB\n" + "IORemapUsed: %8lu kB\n" + "VmapUsed: %8lu kB\n" "VmallocChunk: %8lu kB\n", K(i.totalram), K(i.freeram), @@ -207,6 +209,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, K(committed), (unsigned long)VMALLOC_TOTAL >> 10, vmi.used >> 10, + vmi.used_as_ioremap >> 10, + vmi.used_as_vmap >> 10, vmi.largest_chunk >> 10 ); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] never called printk statement in ide-taskfile.c::wait_drive_not_busy
> Please re-submit this fix in the form of a patch so I can merge it. Here it is. diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 30175c7..aa06daf 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -238,7 +238,7 @@ EXPORT_SYMBOL(task_no_data_intr); static u8 wait_drive_not_busy(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); - int retries = 100; + int retries; u8 stat; /* @@ -246,10 +246,14 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) * This can take up to 10 usec, but we will wait max 1 ms * (drive_cmd_intr() waits that long). */ - while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) - udelay(10); + for (retries = 0; retries < 100; retries++) { + if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) + udelay(10); + else + break; + } - if (!retries) + if (stat & BUSY_STAT) printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); return stat; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] never called printk statement in ide-taskfile.c::wait_drive_not_busy
Hi, Patches appended to this mail fixes a bug explained below. There are two ways to fix the bug. PLEASE CHOOSE BETTER ONE. Look at wait_drive_not_busy in drivers/ide/ide-taskfile.c: static u8 wait_drive_not_busy(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); int retries = 100; u8 stat; /* * Last sector was transfered, wait until drive is ready. * This can take up to 10 usec, but we will wait max 1 ms * (drive_cmd_intr() waits that long). */ while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) udelay(10); if (!retries) printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); return stat; } `printk' is never called because `retries' never holds zero at the outside of `while' loop: when `retries' holds zero at the while's loop condition, `retries' will hold -1 at the if condition. I'm not on this mailing list, so add my address to Cc: when you reply to me. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 30175c7..a74df05 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -246,7 +246,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) * This can take up to 10 usec, but we will wait max 1 ms * (drive_cmd_intr() waits that long). */ - while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) + while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && --retries) udelay(10); if (!retries) diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 30175c7..5e05311 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -249,7 +249,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) udelay(10); - if (!retries) + if (retries < 0) printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); return stat; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] never called printk statement in ide-taskfile.c::wait_drive_not_busy
> On 06/04/2007 10:21 PM, Masatake YAMATO wrote: > > diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c > > index 30175c7..5e05311 100644 > > --- a/drivers/ide/ide-taskfile.c > > +++ b/drivers/ide/ide-taskfile.c > > @@ -249,7 +249,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) > > while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--) > > udelay(10); > > > > - if (!retries) > > + if (retries < 0) > > if (stat & BUSY_STAT) > > > printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); > > Oh, yes. Giving `retries' both roles: loop counter and condition flag for logging may not good. for (retries = 0; retries < 100; retries++) { if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) break; udelay(10); } if (stat & BUSY_STAT) printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); Masatake YAMATO - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH resend] eventfd: make eventfd files distinguishable in /proc/$PID/fd
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files shares one inode object. To provide the way to find endpoints of an eventfd file, this patch adds eventfd identifiers to the output of 'ls -l /proc/$pid/fd' like: ... lrwx--. 1 qemu qemu 64 May 20 04:49 93 -> 'anon_inode:[eventfd:130]' lrwx--. 1 qemu qemu 64 May 20 04:49 94 -> 'anon_inode:[eventfd:131]' ... Here "130" and "131" are added as identifiers newly added. In the case that ida_simple_get returns an error, this change doesn't add an identifier; just use "[eventfd]" as before. Signed-off-by: Masatake YAMATO --- fs/eventfd.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..c18952948110 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -21,6 +21,11 @@ #include #include #include +#include + +/* Worst case buffer size needed for holding an integer. */ +#define ITOA_MAX_LEN 12 +DEFINE_IDA(eventfd_ida); struct eventfd_ctx { struct kref kref; @@ -35,6 +40,7 @@ struct eventfd_ctx { */ __u64 count; unsigned int flags; + int id; }; /** @@ -69,6 +75,8 @@ EXPORT_SYMBOL_GPL(eventfd_signal); static void eventfd_free_ctx(struct eventfd_ctx *ctx) { + if (ctx->id >= 0) + ida_simple_remove(&eventfd_ida, ctx->id); kfree(ctx); } @@ -384,6 +392,7 @@ static int do_eventfd(unsigned int count, int flags) { struct eventfd_ctx *ctx; int fd; + char name[1 + 8 + ITOA_MAX_LEN + 1 + 1] = "[eventfd]"; /* Check the EFD_* constants for consistency. */ BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC); @@ -400,8 +409,11 @@ static int do_eventfd(unsigned int count, int flags) init_waitqueue_head(&ctx->wqh); ctx->count = count; ctx->flags = flags; + ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL); - fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx, + if (ctx->id >= 0) + snprintf(name, sizeof(name), "[eventfd:%d]", ctx->id); + fd = anon_inode_getfd(name, &eventfd_fops, ctx, O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS)); if (fd < 0) eventfd_free_ctx(ctx); -- 2.17.0
[PATCH resend] eventfd: make eventfd files distinguishable in /proc/$PID/fd
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files shares one inode object. To provide the way to find endpoints of an eventfd file, this patch adds eventfd identifiers to the output of 'ls -l /proc/$pid/fd' like: ... lrwx--. 1 qemu qemu 64 May 20 04:49 93 -> 'anon_inode:[eventfd:130]' lrwx--. 1 qemu qemu 64 May 20 04:49 94 -> 'anon_inode:[eventfd:131]' ... Here "130" and "131" are added as identifiers newly added. In the case that ida_simple_get returns an error, this change doesn't add an identifier; just use "[eventfd]" as before. Signed-off-by: Masatake YAMATO --- fs/eventfd.c | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..c18952948110 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -21,6 +21,11 @@ #include #include #include +#include + +/* Worst case buffer size needed for holding an integer. */ +#define ITOA_MAX_LEN 12 +DEFINE_IDA(eventfd_ida); struct eventfd_ctx { struct kref kref; @@ -35,6 +40,7 @@ struct eventfd_ctx { */ __u64 count; unsigned int flags; + int id; }; /** @@ -69,6 +75,8 @@ EXPORT_SYMBOL_GPL(eventfd_signal); static void eventfd_free_ctx(struct eventfd_ctx *ctx) { + if (ctx->id >= 0) + ida_simple_remove(&eventfd_ida, ctx->id); kfree(ctx); } @@ -384,6 +392,7 @@ static int do_eventfd(unsigned int count, int flags) { struct eventfd_ctx *ctx; int fd; + char name[1 + 8 + ITOA_MAX_LEN + 1 + 1] = "[eventfd]"; /* Check the EFD_* constants for consistency. */ BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC); @@ -400,8 +409,11 @@ static int do_eventfd(unsigned int count, int flags) init_waitqueue_head(&ctx->wqh); ctx->count = count; ctx->flags = flags; + ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL); - fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx, + if (ctx->id >= 0) + snprintf(name, sizeof(name), "[eventfd:%d]", ctx->id); + fd = anon_inode_getfd(name, &eventfd_fops, ctx, O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS)); if (fd < 0) eventfd_free_ctx(ctx); -- 2.17.0
Re: [PATCH resend] eventfd: make eventfd files distinguishable in /proc/$PID/fd
On Tue, 11 Dec 2018 17:09:14 -0600, "Serge E. Hallyn" wrote: > On Mon, Dec 10, 2018 at 03:35:46AM +0900, Masatake YAMATO wrote: >> Finding endpoints of an IPC channel is one of essential task to >> understand how a user program works. Procfs and netlink socket provide >> enough hints to find endpoints for IPC channels like pipes, unix >> sockets, and pseudo terminals. However, there is no simple way to find >> endpoints for an eventfd file from userland. An inode number doesn't >> hint. Unlike pipe, all eventfd files shares one inode object. >> >> To provide the way to find endpoints of an eventfd file, this patch >> adds eventfd identifiers to the output of 'ls -l /proc/$pid/fd' like: >> >> ... >> lrwx--. 1 qemu qemu 64 May 20 04:49 93 -> 'anon_inode:[eventfd:130]' >> lrwx--. 1 qemu qemu 64 May 20 04:49 94 -> 'anon_inode:[eventfd:131]' >> ... >> >> Here "130" and "131" are added as identifiers newly added. >> In the case that ida_simple_get returns an error, this change doesn't add >> an identifier; just use "[eventfd]" as before. >> >> Signed-off-by: Masatake YAMATO > > I'm going to love this when I need it :) Thanks. > > Acked-by: Serge Hallyn > Thank you for replying. This is the first time getting replying since my first post, Mon, 21 May 2018 05:18:23 +0900. Can I expect my patch is merged to the mainline? Or should I do something more? Masatake YAMATO >> --- >> fs/eventfd.c | 14 +- >> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/fs/eventfd.c b/fs/eventfd.c >> index 08d3bd602f73..c18952948110 100644 >> --- a/fs/eventfd.c >> +++ b/fs/eventfd.c >> @@ -21,6 +21,11 @@ >> #include >> #include >> #include >> +#include >> + >> +/* Worst case buffer size needed for holding an integer. */ >> +#define ITOA_MAX_LEN 12 >> +DEFINE_IDA(eventfd_ida); >> >> struct eventfd_ctx { >> struct kref kref; >> @@ -35,6 +40,7 @@ struct eventfd_ctx { >> */ >> __u64 count; >> unsigned int flags; >> +int id; >> }; >> >> /** >> @@ -69,6 +75,8 @@ EXPORT_SYMBOL_GPL(eventfd_signal); >> >> static void eventfd_free_ctx(struct eventfd_ctx *ctx) >> { >> +if (ctx->id >= 0) >> +ida_simple_remove(&eventfd_ida, ctx->id); >> kfree(ctx); >> } >> >> @@ -384,6 +392,7 @@ static int do_eventfd(unsigned int count, int flags) >> { >> struct eventfd_ctx *ctx; >> int fd; >> +char name[1 + 8 + ITOA_MAX_LEN + 1 + 1] = "[eventfd]"; >> >> /* Check the EFD_* constants for consistency. */ >> BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC); >> @@ -400,8 +409,11 @@ static int do_eventfd(unsigned int count, int flags) >> init_waitqueue_head(&ctx->wqh); >> ctx->count = count; >> ctx->flags = flags; >> +ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL); >> >> -fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx, >> +if (ctx->id >= 0) >> +snprintf(name, sizeof(name), "[eventfd:%d]", ctx->id); >> +fd = anon_inode_getfd(name, &eventfd_fops, ctx, >>O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS)); >> if (fd < 0) >> eventfd_free_ctx(ctx); >> -- >> 2.17.0
[PATCH] eventfd: prepare id to userspace via fdinfo
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files share the same inode object. To provide the way to find endpoints of an eventfd file, this patch adds "eventfd-id" field to fdinfo of eventfd as identifier. Address for eventfd context is used as id. --- fs/eventfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..fc63ad43d962 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -297,6 +297,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) seq_printf(m, "eventfd-count: %16llx\n", (unsigned long long)ctx->count); spin_unlock_irq(&ctx->wqh.lock); + seq_printf(m, "eventfd-id: %p\n", ctx); } #endif -- 2.17.2
[patch] Show ioremap and vmap in /proc/meminfo
Hi, For long time I've been thought the following equation is correct: The "MemUsage" is about "Active + Inactive + Slab + PageTables + VmallocUsed" in /proc/meminfo. (I'm not only the person. See https://bugzilla.redhat.com/show_bug.cgi?id=243657.) However, some VmallocUsed doesn't really consume MemUsage: ioremap pages and vmap pages consume just virtual address spaces. It is a bit helpful for people who want to understand kernel memory usage to show the number of ioremap and vmap pages in /proc/meminfo. The following patch adds entries for ioremap and vmap to /proc/meminfo. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/fs/proc/internal.h b/fs/proc/internal.h index b215c35..b888c59 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -19,6 +19,8 @@ static inline void proc_sys_init(void) { } struct vmalloc_info { unsigned long used; + unsigned long used_as_ioremap; + unsigned long used_as_vmap; unsigned long largest_chunk; }; @@ -31,6 +33,8 @@ extern void get_vmalloc_info(struct vmalloc_info *vmi); #define get_vmalloc_info(vmi) \ do { \ (vmi)->used = 0;\ + (vmi)->used_as_ioremap = 0; \ + (vmi)->used_as_vmap = 0;\ (vmi)->largest_chunk = 0; \ } while(0) diff --git a/fs/proc/mmu.c b/fs/proc/mmu.c index 25d2d9c..5297df2 100644 --- a/fs/proc/mmu.c +++ b/fs/proc/mmu.c @@ -38,7 +38,9 @@ void get_vmalloc_info(struct vmalloc_info *vmi) unsigned long prev_end; vmi->used = 0; - + vmi->used_as_ioremap = 0; + vmi->used_as_vmap = 0; + if (!vmlist) { vmi->largest_chunk = VMALLOC_TOTAL; } @@ -51,6 +53,8 @@ void get_vmalloc_info(struct vmalloc_info *vmi) for (vma = vmlist; vma; vma = vma->next) { unsigned long addr = (unsigned long) vma->addr; + unsigned long flags; + unsigned long size; /* * Some archs keep another range for modules in vmlist @@ -59,8 +63,15 @@ void get_vmalloc_info(struct vmalloc_info *vmi) continue; if (addr >= VMALLOC_END) break; - - vmi->used += vma->size; + + size = vma->size; + flags = vma->flags; + + vmi->used += size; + if (flags & VM_IOREMAP) + vmi->used_as_ioremap += size; + if (flags & VM_MAP) + vmi->used_as_vmap += size; free_area_size = addr - prev_end; if (vmi->largest_chunk < free_area_size) diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index bee251c..d784c85 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -176,6 +176,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, "Committed_AS: %8lu kB\n" "VmallocTotal: %8lu kB\n" "VmallocUsed: %8lu kB\n" + "IORemapUsed: %8lu kB\n" + "VmapUsed: %8lu kB\n" "VmallocChunk: %8lu kB\n", K(i.totalram), K(i.freeram), @@ -207,6 +209,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off, K(committed), (unsigned long)VMALLOC_TOTAL >> 10, vmi.used >> 10, + vmi.used_as_ioremap >> 10, + vmi.used_as_vmap >> 10, vmi.largest_chunk >> 10 ); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch] fix typo about TBI in e1000 comment
I've found a typo in a comment of e1000 driver. I don't know the Signed-off-by for such a short and trivial patch. Any way I put it here. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 4a22595..50e9c41 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c @@ -3594,7 +3594,7 @@ e1000_update_stats(struct e1000_adapter *adapter) spin_lock_irqsave(&adapter->stats_lock, flags); - /* these counters are modified from e1000_adjust_tbi_stats, + /* these counters are modified from e1000_tbi_adjust_stats, * called from the interrupt context, so they must only * be written while holding adapter->stats_lock */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Fixing signness of parameters in scsi module
Hi, In scsi module I've found some inconsistency between variable type used in module_param_named and type passed to module_param_named as an argument. Especially the inconsistency of `max_scsi_luns' parameter is a bit serious because the description text says "last scsi LUN (should be between 1 and 2^32-1)". I'm not on the mailing list. so please put my address to cc: of your reply. Signed-off-by: Masatake YAMATO <[EMAIL PROTECTED]> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 1bd92b9..f6d7552 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -83,7 +83,7 @@ #else static unsigned int max_scsi_luns = 1; #endif -module_param_named(max_luns, max_scsi_luns, int, S_IRUGO|S_IWUSR); +module_param_named(max_luns, max_scsi_luns, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(max_luns, "last scsi LUN (should be between 1 and 2^32-1)"); @@ -96,14 +96,14 @@ MODULE_PARM_DESC(max_luns, */ static unsigned int max_scsi_report_luns = 511; -module_param_named(max_report_luns, max_scsi_report_luns, int, S_IRUGO|S_IWUSR); +module_param_named(max_report_luns, max_scsi_report_luns, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(max_report_luns, "REPORT LUNS maximum number of LUNS received (should be" " between 1 and 16384)"); static unsigned int scsi_inq_timeout = SCSI_TIMEOUT/HZ+3; -module_param_named(inq_timeout, scsi_inq_timeout, int, S_IRUGO|S_IWUSR); +module_param_named(inq_timeout, scsi_inq_timeout, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(inq_timeout, "Timeout (in seconds) waiting for devices to answer INQUIRY." " Default is 5. Some non-compliant devices need more."); diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index b03aa85..61ca8cd 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -370,7 +370,7 @@ static DECLARE_TRANSPORT_CLASS(fc_rport_ */ static unsigned int fc_dev_loss_tmo = 60; /* seconds */ -module_param_named(dev_loss_tmo, fc_dev_loss_tmo, int, S_IRUGO|S_IWUSR); +module_param_named(dev_loss_tmo, fc_dev_loss_tmo, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(dev_loss_tmo, "Maximum number of seconds that the FC transport should" " insulate the loss of a remote port. Once this value is" - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] trivial: typo in comment in mksysmap
Signed-off-by: Masatake YAMATO --- scripts/mksysmap |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mksysmap b/scripts/mksysmap index 6e133a0..c1b6191 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap @@ -16,7 +16,7 @@ # The second row specify the type of the symbol: # A = Absolute # B = Uninitialised data (.bss) -# C = Comon symbol +# C = Common symbol # D = Initialised data # G = Initialised data for small objects # I = Indirect reference to another symbol -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v4 1/8] bluetooth: /proc/net/ entries for bluetooth protocols
(I resend this mail becasue I got some troubles in mail sending. Andrei, [PATCH v4 [2-8]/8] are the same as [PATCH v3 [2-8]/8]. So I send [PATCH v4 1/8] only here. If I should the rest of v4 patches, please, let me know that.) lsof command can tell the type of socket processes are using. Internal lsof uses inode numbers on socket fs to resolve the type of sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides such inode information. Unfortunately bluetooth related protocols don't provide such inode information. This patch series introduces /proc/net files for the protocols. This patch against af_bluetooth.c provides facility to the implementation of protocols. This patch extends bt_sock_list and introduces two exported function bt_procfs_init, bt_procfs_cleanup. The type bt_sock_list is already used in some of implementation of protocols. bt_procfs_init prepare seq_operations which converts protocol own bt_sock_list data to protocol own proc entry when the entry is accessed. What I, lsof user, need is just inode number of bluetooth socket. However, people may want more information. The bt_procfs_init takes a function pointer for customizing the show handler of seq_operations. In v4 patch, __acquires and __releases attributes are added to suppress sparse warning. Suggested by Andrei Emeltchenko. Signed-off-by: Masatake YAMATO --- include/net/bluetooth/bluetooth.h | 10 +++ net/bluetooth/af_bluetooth.c | 138 + 2 files changed, 148 insertions(+) diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 565d4be..ede0369 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -27,6 +27,7 @@ #include #include +#include #ifndef AF_BLUETOOTH #define AF_BLUETOOTH 31 @@ -202,6 +203,10 @@ enum { struct bt_sock_list { struct hlist_head head; rwlock_t lock; +#ifdef CONFIG_PROC_FS +struct file_operations fops; +int (* custom_seq_show)(struct seq_file *, void *); +#endif }; int bt_sock_register(int proto, const struct net_proto_family *ops); @@ -292,6 +297,11 @@ extern void hci_sock_cleanup(void); extern int bt_sysfs_init(void); extern void bt_sysfs_cleanup(void); +extern int bt_procfs_init(struct module* module, struct net *net, const char *name, + struct bt_sock_list* sk_list, + int (* seq_show)(struct seq_file *, void *)); +extern void bt_procfs_cleanup(struct net *net, const char *name); + extern struct dentry *bt_debugfs; int l2cap_init(void); diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index f7db579..f76cf2f 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -532,6 +532,144 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) } EXPORT_SYMBOL(bt_sock_wait_state); +#ifdef CONFIG_PROC_FS +struct bt_seq_state { + struct bt_sock_list *l; +}; + +static void *bt_seq_start(struct seq_file *seq, loff_t *pos) + __acquires(seq->private->l->lock) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_lock(&l->lock); + return seq_hlist_start_head(&l->head, *pos); +} + +static void *bt_seq_next(struct seq_file *seq, void *v, loff_t *pos) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + return seq_hlist_next(v, &l->head, pos); +} + +static void bt_seq_stop(struct seq_file *seq, void *v) + __releases(seq->private->l->lock) +{ + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + + read_unlock(&l->lock); +} + +static int bt_seq_show(struct seq_file *seq, void *v) +{ + struct sock *sk; + struct bt_sock *bt; + struct bt_seq_state *s = seq->private; + struct bt_sock_list *l = s->l; + bdaddr_t src_baswapped, dst_baswapped; + + if (v == SEQ_START_TOKEN) { + seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); + + if (l->custom_seq_show) { + seq_putc(seq, ' '); + l->custom_seq_show(seq, v); + } + + seq_putc(seq, '\n'); + } else { + sk = sk_entry(v); + bt = bt_sk(sk); + baswap(&src_baswapped, &bt->src); + baswap(&dst_baswapped, &bt->dst); + + seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu", + sk, + atomic_read(&sk->sk_refcnt), + sk_rmem_alloc_get(sk), + sk_wmem_alloc_get(sk), + sock_i_uid(sk), +
[PATCH] x86/iommu: Fix a typo in a macro parameter
Signed-off-by: Masatake YAMATO --- arch/x86/include/asm/iommu_table.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/iommu_table.h b/arch/x86/include/asm/iommu_table.h index 1fb3fd1a83c2..2a0d5f7d1ed1 100644 --- a/arch/x86/include/asm/iommu_table.h +++ b/arch/x86/include/asm/iommu_table.h @@ -66,7 +66,7 @@ struct iommu_table_entry { #define IOMMU_INIT_POST(_detect) \ __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, NULL, NULL, 0) -#define IOMMU_INIT_POST_FINISH(detect) \ +#define IOMMU_INIT_POST_FINISH(_detect) \ __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, NULL, NULL, 1) /* -- 2.17.0
Re: [PATCH] x86/iommu: Fix a typo in a macro parameter
On Wed, 6 Jun 2018 12:37:34 +0200 (CEST), Thomas Gleixner wrote: > On Wed, 6 Jun 2018, Masatake YAMATO wrote: > > Can you please explain why 0 is the wrong value. I don't know such constants, 0 and 1. What I change is just the name of macro parameter as s/detect/_detect/ I don't change the definition of macro. Masatake YAMATO > That's not a typo, that's > a functional change and both the subject line and the changelog itself > should be explanatory. > > Thanks, > > tglx > >> Signed-off-by: Masatake YAMATO >> --- >> arch/x86/include/asm/iommu_table.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/x86/include/asm/iommu_table.h >> b/arch/x86/include/asm/iommu_table.h >> index 1fb3fd1a83c2..2a0d5f7d1ed1 100644 >> --- a/arch/x86/include/asm/iommu_table.h >> +++ b/arch/x86/include/asm/iommu_table.h >> @@ -66,7 +66,7 @@ struct iommu_table_entry { >> #define IOMMU_INIT_POST(_detect)\ >> __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, NULL, NULL, 0) >> >> -#define IOMMU_INIT_POST_FINISH(detect) >> \ >> +#define IOMMU_INIT_POST_FINISH(_detect) >> \ >> __IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, NULL, NULL, 1) >> >> /* >> -- >> 2.17.0 >> >>
Re: [PATCH] x86/iommu: Fix a typo in a macro parameter
On Wed, 6 Jun 2018 14:41:57 +0200 (CEST), Thomas Gleixner wrote: > On Wed, 6 Jun 2018, Thomas Gleixner wrote: >> On Wed, 6 Jun 2018, Masatake YAMATO wrote: >> > On Wed, 6 Jun 2018 12:37:34 +0200 (CEST), Thomas Gleixner >> > wrote: >> > > On Wed, 6 Jun 2018, Masatake YAMATO wrote: >> > > >> > > Can you please explain why 0 is the wrong value. >> > >> > I don't know such constants, 0 and 1. >> > >> > What I change is just the name of macro parameter as >> > >> > s/detect/_detect/ >> >> OOps. Misread the patch. Sorry. > > But the fix is pretty pointless. IOMMU_INIT_POST_FINISH() is completely > unused and should just be removed. Oh, I see. Thank you for taking your time. Masatake YAMATO > Thanks, > > tglx
[PATCH RESEND] eventfd: prepare id to userspace via fdinfo
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files share the same inode object. To provide the way to find endpoints of an eventfd file, this patch adds "eventfd-id" field to fdinfo of eventfd as identifier. Address for eventfd context is used as id. Typical applicaiton utilizing the information is lsof. Signed-off-by: Masatake YAMATO --- fs/eventfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..fc63ad43d962 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -297,6 +297,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) seq_printf(m, "eventfd-count: %16llx\n", (unsigned long long)ctx->count); spin_unlock_irq(&ctx->wqh.lock); + seq_printf(m, "eventfd-id: %p\n", ctx); } #endif -- 2.17.2
[PATCH v2] eventfd: prepare id to userspace via fdinfo
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files share the same inode object. To provide the way to find endpoints of an eventfd file, this patch adds "eventfd-id" field to /proc/PID/fdinfo of eventfd as identifier. Integers managed by an IDA are used as ids. A tool like lsof can utilize the information to print endpoints. Change in v2: Use integers as ids instead of memory addresses of eventfd contexts. Signed-off-by: Masatake YAMATO --- fs/eventfd.c | 8 1 file changed, 8 insertions(+) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..ce8fa15cebe5 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -21,6 +21,9 @@ #include #include #include +#include + +DEFINE_IDA(eventfd_ida); struct eventfd_ctx { struct kref kref; @@ -35,6 +38,7 @@ struct eventfd_ctx { */ __u64 count; unsigned int flags; + int id; }; /** @@ -69,6 +73,8 @@ EXPORT_SYMBOL_GPL(eventfd_signal); static void eventfd_free_ctx(struct eventfd_ctx *ctx) { + if (ctx->id >= 0) + ida_simple_remove(&eventfd_ida, ctx->id); kfree(ctx); } @@ -297,6 +303,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) seq_printf(m, "eventfd-count: %16llx\n", (unsigned long long)ctx->count); spin_unlock_irq(&ctx->wqh.lock); + seq_printf(m, "eventfd-id: %d\n", ctx->id); } #endif @@ -400,6 +407,7 @@ static int do_eventfd(unsigned int count, int flags) init_waitqueue_head(&ctx->wqh); ctx->count = count; ctx->flags = flags; + ctx->id = ida_simple_get(&eventfd_ida, 0, 0, GFP_KERNEL); fd = anon_inode_getfd("[eventfd]", &eventfd_fops, ctx, O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS)); -- 2.17.2
[PATCH] wait: swap EXIT_ZOMBIE(Z) and EXIT_DEAD(X) chars in TASK_STATE_TO_CHAR_STR
In ad86622b478eaafdc25b74237df82b10fce6326d the order of task state definitions were changed: EXIT_DEAD and EXIT_ZOMBIE were swapped. Though the charterers for the states in TASK_STATE_TO_CHAR_STR string were not updated. This patch synchronizes the string to the order of definitions. Signed-off-by: Masatake YAMATO --- include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 25f54c7..21fbdae 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -220,7 +220,7 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq); #define TASK_PARKED512 #define TASK_STATE_MAX 1024 -#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP" +#define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWP" extern char ___assert_task_state[1 - 2*!!( sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)]; -- 1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] intel_ips: fix a type in error message
Signed-off-by: Masatake YAMATO --- drivers/platform/x86/intel_ips.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index c0242ed..ecd36e3 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c @@ -593,7 +593,7 @@ static void ips_disable_gpu_turbo(struct ips_driver *ips) return; if (!ips->gpu_turbo_disable()) - dev_err(&ips->dev->dev, "failed to disable graphis turbo\n"); + dev_err(&ips->dev->dev, "failed to disable graphics turbo\n"); else ips->__gpu_turbo_on = false; } -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] dynamic_debug: Fix a typo in comment
Signed-off-by: Masatake YAMATO --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 527799d..d8f3d31 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -641,7 +641,7 @@ static __init int ddebug_setup_query(char *str) __setup("ddebug_query=", ddebug_setup_query); /* - * File_ops->write method for /dynamic_debug/conrol. Gathers the + * File_ops->write method for /dynamic_debug/control. Gathers the * command text from userspace, parses and executes it. */ #define USER_BUF_PAGE 4096 -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH RESEND] eventfd: prepare id to userspace via fdinfo
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files share the same inode object. To provide the way to find endpoints of an eventfd file, this patch adds "eventfd-id" field to /proc/PID/fdinfo of eventfd as identifier. Address for eventfd context is used as id. A tool like lsof can utilize the information to print endpoints. Signed-off-by: Masatake YAMATO --- fs/eventfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..fc63ad43d962 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -297,6 +297,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) seq_printf(m, "eventfd-count: %16llx\n", (unsigned long long)ctx->count); spin_unlock_irq(&ctx->wqh.lock); + seq_printf(m, "eventfd-id: %p\n", ctx); } #endif -- 2.17.2
Re: [PATCH RESEND] eventfd: prepare id to userspace via fdinfo
Thank you for the comment. On Wed, 20 Mar 2019 12:05:25 -0700, Andrew Morton wrote: > On Wed, 20 Mar 2019 18:29:29 +0900 Masatake YAMATO wrote: > >> Finding endpoints of an IPC channel is one of essential task to >> understand how a user program works. Procfs and netlink socket provide >> enough hints to find endpoints for IPC channels like pipes, unix >> sockets, and pseudo terminals. However, there is no simple way to find >> endpoints for an eventfd file from userland. An inode number doesn't >> hint. Unlike pipe, all eventfd files share the same inode object. >> >> To provide the way to find endpoints of an eventfd file, this patch >> adds "eventfd-id" field to /proc/PID/fdinfo of eventfd as identifier. >> Address for eventfd context is used as id. >> >> A tool like lsof can utilize the information to print endpoints. >> >> ... >> >> --- a/fs/eventfd.c >> +++ b/fs/eventfd.c >> @@ -297,6 +297,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, >> struct file *f) >> seq_printf(m, "eventfd-count: %16llx\n", >> (unsigned long long)ctx->count); >> spin_unlock_irq(&ctx->wqh.lock); >> +seq_printf(m, "eventfd-id: %p\n", ctx); >> } >> #endif > > Is it a good idea to use a bare kernel address for this? How does this > interact with printk pointer randomization and hashing? > My understanding is that an address printed with %p for a bare kernel address is stable after ptr_key in vsprintf.c is filled, and ptr_key is filled enough early stage. so, for my usecase, resolving IPC endpoints, printing a bare kernel address with %p may be enough. Am I missing something? For the same purpose, I submitted a ida based patch a year ago. (https://patchwork.kernel.org/patch/10413589/) I quote it here for getting comments: This one doesn't use any bare kernel addresses. I implemented new one (%p version) bacause is is much shorter. Do you think ida based one is better than %p based one? Masatake YAMATO
[PATCH RESEND] eventfd: prepare id to userspace via fdinfo
Finding endpoints of an IPC channel is one of essential task to understand how a user program works. Procfs and netlink socket provide enough hints to find endpoints for IPC channels like pipes, unix sockets, and pseudo terminals. However, there is no simple way to find endpoints for an eventfd file from userland. An inode number doesn't hint. Unlike pipe, all eventfd files share the same inode object. To provide the way to find endpoints of an eventfd file, this patch adds "eventfd-id" field to fdinfo of eventfd as identifier. Address for eventfd context is used as id. Typical applicaiton utilizing the information is lsof. Signed-off-by: Masatake YAMATO --- fs/eventfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/eventfd.c b/fs/eventfd.c index 08d3bd602f73..fc63ad43d962 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -297,6 +297,7 @@ static void eventfd_show_fdinfo(struct seq_file *m, struct file *f) seq_printf(m, "eventfd-count: %16llx\n", (unsigned long long)ctx->count); spin_unlock_irq(&ctx->wqh.lock); + seq_printf(m, "eventfd-id: %p\n", ctx); } #endif -- 2.17.2
[PATCH] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 12 +++- drivers/tty/tty_io.c | 14 ++ include/linux/tty_driver.h | 5 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index a23fa5e..e7c9b17 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -674,6 +674,13 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +#ifdef CONFIG_PROC_FS +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} +#endif + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -687,7 +694,10 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .ioctl = pty_unix98_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, +#ifdef CONFIG_PROC_FS + .show_fdinfo = pty_show_fdinfo, +#endif }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 734a635..6c0f180 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -105,6 +105,8 @@ #include #include +#include + #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP # define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args) @@ -470,6 +472,15 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +#ifdef CONFIG_PROC_FS +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo (tty, m); +} +#endif + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -480,6 +491,9 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, +#ifdef CONFIG_PROC_FS + .show_fdinfo= tty_show_fdinfo, +#endif }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..499823d 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,10 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); +#ifdef CONFIG_PROC_FS + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); +#endif + #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.3
[RESEND PATCH] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 12 +++- drivers/tty/tty_io.c | 14 ++ include/linux/tty_driver.h | 5 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 66b59a1..4c8cf03 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -674,6 +674,13 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +#ifdef CONFIG_PROC_FS +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} +#endif + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -687,7 +694,10 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .ioctl = pty_unix98_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, +#ifdef CONFIG_PROC_FS + .show_fdinfo = pty_show_fdinfo, +#endif }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index e6d1a65..24a999d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -106,6 +106,8 @@ #include #include +#include + #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP # define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args) @@ -471,6 +473,15 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +#ifdef CONFIG_PROC_FS +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo (tty, m); +} +#endif + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -481,6 +492,9 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, +#ifdef CONFIG_PROC_FS + .show_fdinfo= tty_show_fdinfo, +#endif }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..499823d 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,10 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); +#ifdef CONFIG_PROC_FS + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); +#endif + #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.3
[RESEND PATCH] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 12 +++- drivers/tty/tty_io.c | 14 ++ include/linux/tty_driver.h | 5 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 66b59a1..4c8cf03 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -674,6 +674,13 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +#ifdef CONFIG_PROC_FS +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} +#endif + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -687,7 +694,10 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .ioctl = pty_unix98_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, +#ifdef CONFIG_PROC_FS + .show_fdinfo = pty_show_fdinfo, +#endif }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index e6d1a65..24a999d 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -106,6 +106,8 @@ #include #include +#include + #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP # define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args) @@ -471,6 +473,15 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +#ifdef CONFIG_PROC_FS +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo (tty, m); +} +#endif + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -481,6 +492,9 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, +#ifdef CONFIG_PROC_FS + .show_fdinfo= tty_show_fdinfo, +#endif }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..499823d 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,10 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); +#ifdef CONFIG_PROC_FS + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); +#endif + #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.3
[PATCH RESEND] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 12 +++- drivers/tty/tty_io.c | 15 +++ include/linux/tty_driver.h | 5 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 6579957..9357c6a 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -669,6 +669,13 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +#ifdef CONFIG_PROC_FS +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} +#endif + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -682,7 +689,10 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .ioctl = pty_unix98_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, +#ifdef CONFIG_PROC_FS + .show_fdinfo = pty_show_fdinfo, +#endif }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 0c150b5..4a00e34 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -106,6 +106,8 @@ #include #include +#include + #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP # define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args) @@ -412,6 +414,16 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +#ifdef CONFIG_PROC_FS +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo(tty, m); +} +#endif + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -422,6 +434,9 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, +#ifdef CONFIG_PROC_FS + .show_fdinfo= tty_show_fdinfo, +#endif }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..499823d 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,10 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); +#ifdef CONFIG_PROC_FS + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); +#endif + #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.4
[PATCH v2] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Change in v2: Remove all #ifdef CONFIG_PROC_FS/#endif. Suggested by Greg KH. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 8 +++- drivers/tty/tty_io.c | 9 + include/linux/tty_driver.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index d1399aa..ce27be4 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -742,6 +742,11 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -756,7 +761,8 @@ static const struct tty_operations ptm_unix98_ops = { .ioctl = pty_unix98_ioctl, .compat_ioctl = pty_unix98_compat_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, + .show_fdinfo = pty_show_fdinfo, }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 974b13d..c3c8fd0 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -462,6 +462,14 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo(tty, m); +} + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -472,6 +480,7 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, + .show_fdinfo= tty_show_fdinfo, }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..570b05b 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,7 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.4
[PATCH RESEND] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 12 +++- drivers/tty/tty_io.c | 15 +++ include/linux/tty_driver.h | 5 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 6579957..9357c6a 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -669,6 +669,13 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +#ifdef CONFIG_PROC_FS +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} +#endif + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -682,7 +689,10 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .ioctl = pty_unix98_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, +#ifdef CONFIG_PROC_FS + .show_fdinfo = pty_show_fdinfo, +#endif }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 0c150b5..4a00e34 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -106,6 +106,8 @@ #include #include +#include + #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP # define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args) @@ -412,6 +414,16 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +#ifdef CONFIG_PROC_FS +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo(tty, m); +} +#endif + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -422,6 +434,9 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, +#ifdef CONFIG_PROC_FS + .show_fdinfo= tty_show_fdinfo, +#endif }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..499823d 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,10 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); +#ifdef CONFIG_PROC_FS + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); +#endif + #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.4
[PATCH RESEND] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 12 +++- drivers/tty/tty_io.c | 15 +++ include/linux/tty_driver.h | 5 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 6579957..9357c6a 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -669,6 +669,13 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +#ifdef CONFIG_PROC_FS +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} +#endif + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -682,7 +689,10 @@ static const struct tty_operations ptm_unix98_ops = { .unthrottle = pty_unthrottle, .ioctl = pty_unix98_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, +#ifdef CONFIG_PROC_FS + .show_fdinfo = pty_show_fdinfo, +#endif }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 0c150b5..4a00e34 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -106,6 +106,8 @@ #include #include +#include + #undef TTY_DEBUG_HANGUP #ifdef TTY_DEBUG_HANGUP # define tty_debug_hangup(tty, f, args...) tty_debug(tty, f, ##args) @@ -412,6 +414,16 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +#ifdef CONFIG_PROC_FS +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo(tty, m); +} +#endif + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -422,6 +434,9 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, +#ifdef CONFIG_PROC_FS + .show_fdinfo= tty_show_fdinfo, +#endif }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..499823d 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,10 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); +#ifdef CONFIG_PROC_FS + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); +#endif + #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.4
[PATCH v2 resend] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Change in v2: Remove all #ifdef CONFIG_PROC_FS/#endif. Suggested by Greg KH. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 8 +++- drivers/tty/tty_io.c | 9 + include/linux/tty_driver.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index d1399aa..ce27be4 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -742,6 +742,11 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -756,7 +761,8 @@ static const struct tty_operations ptm_unix98_ops = { .ioctl = pty_unix98_ioctl, .compat_ioctl = pty_unix98_compat_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, + .show_fdinfo = pty_show_fdinfo, }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 974b13d..c3c8fd0 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -462,6 +462,14 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo(tty, m); +} + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -472,6 +480,7 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, + .show_fdinfo= tty_show_fdinfo, }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..570b05b 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,7 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.4
[PATCH v2 resend] pty: show associative slave of ptmx in fdinfo
This patch adds "tty-index" field to /proc/PID/fdinfo/N if N specifies /dev/ptmx. The field shows the index of associative slave pts. Though a minor number is given for each pts instance, ptmx is not. It means there is no way in user-space to know the association between file descriptors for pts/n and ptmx. (n = 0, 1, ...) This is different from pipe. About pipe such association can be solved by inode of pipefs. Providing the way to know the association between pts/n and ptmx helps users understand the status of running system. lsof can utilize this field. Change in v2: Remove all #ifdef CONFIG_PROC_FS/#endif. Suggested by Greg KH. Signed-off-by: Masatake YAMATO --- drivers/tty/pty.c | 8 +++- drivers/tty/tty_io.c | 9 + include/linux/tty_driver.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index d1399aa..ce27be4 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -742,6 +742,11 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) } } +static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) +{ + seq_printf(m, "tty-index:\t%d\n", tty->index); +} + static const struct tty_operations ptm_unix98_ops = { .lookup = ptm_unix98_lookup, .install = pty_unix98_install, @@ -756,7 +761,8 @@ static const struct tty_operations ptm_unix98_ops = { .ioctl = pty_unix98_ioctl, .compat_ioctl = pty_unix98_compat_ioctl, .resize = pty_resize, - .cleanup = pty_cleanup + .cleanup = pty_cleanup, + .show_fdinfo = pty_show_fdinfo, }; static const struct tty_operations pty_unix98_ops = { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 974b13d..c3c8fd0 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -462,6 +462,14 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) return -ENOTTY; } +static void tty_show_fdinfo(struct seq_file *m, struct file *file) +{ + struct tty_struct *tty = file_tty(file); + + if (tty && tty->ops && tty->ops->show_fdinfo) + tty->ops->show_fdinfo(tty, m); +} + static const struct file_operations tty_fops = { .llseek = no_llseek, .read = tty_read, @@ -472,6 +480,7 @@ static const struct file_operations tty_fops = { .open = tty_open, .release= tty_release, .fasync = tty_fasync, + .show_fdinfo= tty_show_fdinfo, }; static const struct file_operations console_fops = { diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e..570b05b 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -243,6 +243,7 @@ #include #include #include +#include struct tty_struct; struct tty_driver; @@ -285,6 +286,7 @@ struct tty_operations { int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount); + void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); #ifdef CONFIG_CONSOLE_POLL int (*poll_init)(struct tty_driver *driver, int line, char *options); int (*poll_get_char)(struct tty_driver *driver, int line); -- 2.9.4