[PATCH] Tools: hv: kvp: ensure kvp device fd is closed on exec
KVP daemon does fork()/exec() (with popen()) so we need to close our fds to avoid sharing them with child processes. The immediate implication of not doing so I see is SELinux complaining about 'ip' trying to access '/dev/vmbus/hv_kvp'. Signed-off-by: Vitaly Kuznetsov --- tools/hv/hv_kvp_daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index 0d9f48e..bc7adb8 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c @@ -1433,7 +1433,7 @@ int main(int argc, char *argv[]) openlog("KVP", 0, LOG_USER); syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); - kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR); + kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR | O_CLOEXEC); if (kvp_fd < 0) { syslog(LOG_ERR, "open /dev/vmbus/hv_kvp failed; error: %d %s", -- 2.5.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v13 net-next 1/1] hv_sock: introduce Hyper-V Sockets
From: Dexuan Cui Date: Wed, 29 Jun 2016 11:30:40 + > @@ -1509,4 +1509,18 @@ static inline void commit_rd_index(struct > vmbus_channel *channel) > } > > > +struct vmpipe_proto_header { > + u32 pkt_type; It is wasteful to have two empty lines before this structure definition, one is sufficient. > +/* > + * This is the address fromat of Hyper-V Sockets. > + * Note: here we just borrow the kernel's built-in type uuid_le. When > + * an application calls bind() or connect(), the 2 members of struct > + * sockaddr_hv must be of GUID. > + * The GUID format differs from the UUID format only in the byte order of > + * the first 3 fields. Refer to: > + * https://en.wikipedia.org/wiki/Globally_unique_identifier > + */ Comments should be of the form: /* Like * this. */ Rather than: /* * Like * this. */ > + __le16 reserved;/* Must be Zero*/ Why does an ignored, reserved, field need an endianness? Just use plain "u16" for this. > +static > +void hvsock_enqueue_accept(struct sock *listener, struct sock *connected) Don't split the declaration after "static" with a newline, instead use: static void hvsock_enqueue_accept(struct sock *listener, struct sock *connected) > +{ > + struct hvsock_sock *hvlistener; > + struct hvsock_sock *hvconnected; Please order local variables from logest to shortest line. > +static struct sock *hvsock_dequeue_accept(struct sock *listener) > +{ > + struct hvsock_sock *hvlistener; > + struct hvsock_sock *hvconnected; Likewise. > +static void hvsock_sk_destruct(struct sock *sk) > +{ > + struct hvsock_sock *hvsk = sk_to_hvsock(sk); > + struct vmbus_channel *channel = hvsk->channel; Likewise. > +/* This function runs in the tasklet context of process_chn_event() */ > +static void hvsock_on_channel_cb(void *ctx) > +{ > + struct sock *sk = (struct sock *)ctx; > + struct hvsock_sock *hvsk = sk_to_hvsock(sk); > + struct vmbus_channel *channel = hvsk->channel; > + bool can_read, can_write; Likewise. > +static int hvsock_open_connection(struct vmbus_channel *channel) > +{ > + struct hvsock_sock *hvsk, *new_hvsk; > + struct sockaddr_hv hv_addr; > + struct sock *sk, *new_sk; > + unsigned char conn_from_host; Likewise. > +static int hvsock_connect_wait(struct socket *sock, > +int flags, int current_ret) > +{ > + struct sock *sk = sock->sk; > + struct hvsock_sock *hvsk = sk_to_hvsock(sk); Likewise. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH v13 net-next 1/1] hv_sock: introduce Hyper-V Sockets
> From: David Miller [mailto:da...@davemloft.net] > Sent: Thursday, June 30, 2016 20:45 > To: Dexuan Cui > Cc: gre...@linuxfoundation.org; net...@vger.kernel.org; linux- > ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de; > a...@canonical.com; jasow...@redhat.com; vkuzn...@redhat.com; > cav...@redhat.com; KY Srinivasan ; Haiyang Zhang > ; j...@perches.com; rolf.neugeba...@docker.com > Subject: Re: [PATCH v13 net-next 1/1] hv_sock: introduce Hyper-V Sockets > > From: Dexuan Cui > Date: Wed, 29 Jun 2016 11:30:40 + > > > @@ -1509,4 +1509,18 @@ static inline void commit_rd_index(struct > vmbus_channel *channel) > > } > > > > > > +struct vmpipe_proto_header { > > + u32 pkt_type; > > It is wasteful to have two empty lines before this structure definition, one > is sufficient. > > ... Hi David, Thank you for pointing out the issues! I'll fix all of them, and check all the similar issues in the patch. Will post a new version ASAP. Thanks, -- Dexuan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v14 net-next 0/1] introduce Hyper-V VM Sockets(hv_sock)
Hyper-V Sockets (hv_sock) supplies a byte-stream based communication mechanism between the host and the guest. It's somewhat like TCP over VMBus, but the transportation layer (VMBus) is much simpler than IP. With Hyper-V Sockets, applications between the host and the guest can talk to each other directly by the traditional BSD-style socket APIs. Hyper-V Sockets is only available on new Windows hosts, like Windows Server 2016. More info is in this article "Make your own integration services": https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/make_mgmt_service The patch implements the necessary support in the guest side by introducing a new socket address family AF_HYPERV. You can also get the patch by: https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160629_v14 Note: the VMBus driver side's supporting patches have been in the mainline tree. I know the kernel has already had a VM Sockets driver (AF_VSOCK) based on VMware VMCI (net/vmw_vsock/, drivers/misc/vmw_vmci), and KVM is proposing AF_VSOCK of virtio version: http://marc.info/?l=linux-netdev&m=145952064004765&w=2 However, though Hyper-V Sockets may seem conceptually similar to AF_VOSCK, there are differences in the transportation layer, and IMO these make the direct code reusing impractical: 1. In AF_VSOCK, the endpoint type is: , but in AF_HYPERV, the endpoint type is: . Here GUID is 128-bit. 2. AF_VSOCK supports SOCK_DGRAM, while AF_HYPERV doesn't. 3. AF_VSOCK supports some special sock opts, like SO_VM_SOCKETS_BUFFER_SIZE, SO_VM_SOCKETS_BUFFER_MIN/MAX_SIZE and SO_VM_SOCKETS_CONNECT_TIMEOUT. These are meaningless to AF_HYPERV. 4. Some AF_VSOCK's VMCI transportation ops are meanless to AF_HYPERV/VMBus, like .notify_recv_init .notify_recv_pre_block .notify_recv_pre_dequeue .notify_recv_post_dequeue .notify_send_init .notify_send_pre_block .notify_send_pre_enqueue .notify_send_post_enqueue etc. So I think we'd better introduce a new address family: AF_HYPERV. Please review the patch. Looking forward to your comments, especially comments from David. :-) Changes since v1: - updated "[PATCH 6/7] hvsock: introduce Hyper-V VM Sockets feature" - added __init and __exit for the module init/exit functions - net/hv_sock/Kconfig: "default m" -> "default m if HYPERV" - MODULE_LICENSE: "Dual MIT/GPL" -> "Dual BSD/GPL" Changes since v2: - fixed various coding issue pointed out by David Miller - fixed indentation issues - removed pr_debug in net/hv_sock/af_hvsock.c - used reverse-Chrismas-tree style for local variables. - EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL Changes since v3: - fixed a few coding issue pointed by Vitaly Kuznetsov and Dan Carpenter - fixed the ret value in vmbus_recvpacket_hvsock on error - fixed the style of multi-line comment: vmbus_get_hvsock_rw_status() Changes since v4 (https://lkml.org/lkml/2015/7/28/404): - addressed all the comments about V4. - treat the hvsock offers/channels as special VMBus devices - add a mechanism to pass hvsock events to the hvsock driver - fixed some corner cases with proper locking when a connection is closed - rebased to the latest Greg's tree Changes since v5 (https://lkml.org/lkml/2015/12/24/103): - addressed the coding style issues (Vitaly Kuznetsov & David Miller, thanks!) - used a better coding for the per-channel rescind callback (Thank Vitaly!) - avoided the introduction of new VMBUS driver APIs vmbus_sendpacket_hvsock() and vmbus_recvpacket_hvsock() and used vmbus_sendpacket()/vmbus_recvpacket() in the higher level (i.e., the vmsock driver). Thank Vitaly! Changes since v6 (http://lkml.iu.edu/hypermail/linux/kernel/1601.3/01813.html) - only a few minor changes of coding style and comments Changes since v7 - a few minor changes of coding style: thanks, Joe Perches! - added some lines of comments about GUID/UUID before the struct sockaddr_hv. Changes since v8 - removed the unnecessary __packed for some definitions: thanks, David! - hvsock_open_connection: use offer.u.pipe.user_def[0] to know the connection and reorganized the function direction - reorganized the code according to suggestions from Cathy Avery: split big functions into small ones, set .setsockopt and getsockopt to sock_no_setsockopt/sock_no_getsockopt - inline'd some small list helper functions Changes since v9 - minimized struct hvsock_sock by making the send/recv buffers pointers. the buffers are allocated by kmalloc() in __hvsock_create() now. - minimized the sizes of the send/recv buffers and the vmbus ringbuffers. Changes since v10 1) add module params: send_ring_page, recv_ring_page. They can be used to enlarge the ringbuffer size to get better performance, e.g., # modprobe hv_sock recv_ring_page=16 send_ring_page=16 By default, recv_ring_page is 3 and send_ring_page is 2. 2) add module param max_socket_number (the default is 1024). A user can enlarge the number to create more than 1024 hv_sock sockets. By default, 1024 sockets take about 1024 * (3+2+1+1) * 4KB = 28M bytes. (H
[PATCH v14 net-next 1/1] hv_sock: introduce Hyper-V Sockets
Hyper-V Sockets (hv_sock) supplies a byte-stream based communication mechanism between the host and the guest. It's somewhat like TCP over VMBus, but the transportation layer (VMBus) is much simpler than IP. With Hyper-V Sockets, applications between the host and the guest can talk to each other directly by the traditional BSD-style socket APIs. Hyper-V Sockets is only available on new Windows hosts, like Windows Server 2016. More info is in this article "Make your own integration services": https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/make_mgmt_service The patch implements the necessary support in the guest side by introducing a new socket address family AF_HYPERV. Signed-off-by: Dexuan Cui Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Vitaly Kuznetsov Cc: Cathy Avery --- You can also get the patch here (8ba95c8ec9): https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160629_v14 For the change log before v12, please see https://lkml.org/lkml/2016/5/15/31 In v12, the changes are mainly the following: 1) remove the module params as David suggested. 2) use 5 exact pages for VMBus send/recv rings, respectively. The host side's design of the feature requires 5 exact pages for recv/send rings respectively -- this is suboptimal considering memory consumption, however unluckily we have to live with it, before the host comes up with a new design in the future. :-( 3) remove the per-connection static send/recv buffers Instead, we allocate and free the buffers dynamically only when we recv/send data. This means: when a connection is idle, no memory is consumed as recv/send buffers at all. In v13: I return ENOMEM on buffer alllocation failure Actually "man read/write" says "Other errors may occur, depending on the object connected to fd". "man send/recv" indeed lists ENOMEM. Considering AF_HYPERV is a new socket type, ENOMEM seems OK here. In the long run, I think we should add a new API in the VMBus driver, allowing data copy from VMBus ringbuffer into user mode buffer directly. This way, we can even eliminate this temporary buffer. In v14: fix some coding style issues pointed out by David. Looking forward to your comments! MAINTAINERS |2 + include/linux/hyperv.h | 13 + include/linux/socket.h |4 +- include/net/af_hvsock.h | 59 ++ include/uapi/linux/hyperv.h | 24 + net/Kconfig |1 + net/Makefile|1 + net/hv_sock/Kconfig | 10 + net/hv_sock/Makefile|3 + net/hv_sock/af_hvsock.c | 1519 +++ 10 files changed, 1635 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 50f69ba..6eaa26f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5514,7 +5514,9 @@ F:drivers/pci/host/pci-hyperv.c F: drivers/net/hyperv/ F: drivers/scsi/storvsc_drv.c F: drivers/video/fbdev/hyperv_fb.c +F: net/hv_sock/ F: include/linux/hyperv.h +F: include/net/af_hvsock.h F: tools/hv/ F: Documentation/ABI/stable/sysfs-bus-vmbus diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 50f493e..1cda6ea5 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1508,5 +1508,18 @@ static inline void commit_rd_index(struct vmbus_channel *channel) vmbus_set_event(channel); } +struct vmpipe_proto_header { + u32 pkt_type; + u32 data_size; +}; + +#define HVSOCK_HEADER_LEN (sizeof(struct vmpacket_descriptor) + \ +sizeof(struct vmpipe_proto_header)) + +/* See 'prev_indices' in hv_ringbuffer_read(), hv_ringbuffer_write() */ +#define PREV_INDICES_LEN (sizeof(u64)) +#define HVSOCK_PKT_LEN(payload_len)(HVSOCK_HEADER_LEN + \ + ALIGN((payload_len), 8) + \ + PREV_INDICES_LEN) #endif /* _HYPERV_H */ diff --git a/include/linux/socket.h b/include/linux/socket.h index b5cc5a6..0b68b58 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -202,8 +202,9 @@ struct ucred { #define AF_VSOCK 40 /* vSockets */ #define AF_KCM 41 /* Kernel Connection Multiplexor*/ #define AF_QIPCRTR 42 /* Qualcomm IPC Router */ +#define AF_HYPERV 43 /* Hyper-V Sockets */ -#define AF_MAX 43 /* For now.. */ +#define AF_MAX 44 /* For now.. */ /* Protocol families, same as address families. */ #define PF_UNSPEC AF_UNSPEC @@ -251,6 +252,7 @@ struct ucred { #define PF_VSOCK AF_VSOCK #define PF_KCM AF_KCM #define PF_QIPCRTR AF_QIPCRTR +#define PF_HYPERV AF_HYPERV #define PF_MAX AF_MAX /* Maximum queue length specifiable by listen. */ diff --git a/include/net/af_hvsock.h b/include/net/af_hvsock.h new file mode 100644 index 000..20d23d5 --- /dev/null +++ b/include/net/af_h
Re: [PATCH v14 net-next 1/1] hv_sock: introduce Hyper-V Sockets
On Thu, Jun 30, Dexuan Cui wrote: > -#define AF_MAX 43 /* For now.. */ > +#define AF_MAX 44 /* For now.. */ Should this patch also change the places where AF_MAX is used, like all the arrays in net/core/sock.c? Olaf signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RE: [PATCH v14 net-next 1/1] hv_sock: introduce Hyper-V Sockets
> From: Olaf Hering [mailto:o...@aepfle.de] > Sent: Friday, July 1, 2016 0:12 > To: Dexuan Cui > Cc: da...@davemloft.net; gre...@linuxfoundation.org; > net...@vger.kernel.org; linux-ker...@vger.kernel.org; > de...@linuxdriverproject.org; a...@canonical.com; jasow...@redhat.com; > Vitaly Kuznetsov ; Cathy Avery ; > KY Srinivasan ; Haiyang Zhang > ; j...@perches.com; Rolf Neugebauer > > Subject: Re: [PATCH v14 net-next 1/1] hv_sock: introduce Hyper-V Sockets > > On Thu, Jun 30, Dexuan Cui wrote: > > > -#define AF_MAX 43 /* For now.. */ > > +#define AF_MAX 44 /* For now.. */ > > Should this patch also change the places where AF_MAX is used, > like all the arrays in net/core/sock.c? > > Olaf Thanks for the reminder, Olaf! I think we may as well make a separate patch for this. It is in my To-Do list. Thanks, -- Dexuan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: comedi: comedi_test: fix timer race conditions
Commit 73e0e4dfed4c ("staging: comedi: comedi_test: fix timer lock-up") fixed a lock-up in the timer routine `waveform_ai_timer()` (which was called `waveform_ai_interrupt()` at the time) caused by commit 240512474424 ("staging: comedi: comedi_test: use comedi_handle_events()"). However, it introduced a race condition that can result in the timer routine misbehaving, such as accessing freed memory or dereferencing a NULL pointer. 73e0... changed the timer routine to do nothing unless a `WAVEFORM_AI_RUNNING` flag was set, and changed `waveform_ai_cancel()` to clear the flag and replace a call to `del_timer_sync()` with a call to `del_timer()`. `waveform_ai_cancel()` may be called from the timer routine itself (via `comedi_handle_events()`), or from `do_cancel()`. (`do_cancel()` is called as a result of a file operation (usually a `COMEDI_CANCEL` ioctl command, or a release), or during device removal.) When called from `do_cancel()`, the call to `waveform_ai_cancel()` is followed by a call to `do_become_nonbusy()`, which frees up stuff for the current asynchronous command under the assumption that it is now safe to do so. The race condition occurs when the timer routine `waveform_ai_timer()` checks the `WAVEFORM_AI_RUNNING` flag just before it is cleared by `waveform_ai_cancel()`, and is still running during the call to `do_become_nonbusy()`. In particular, it can lead to a NULL pointer dereference: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] waveform_ai_timer+0x17d/0x290 [comedi_test] That corresponds to this line in `waveform_ai_timer()`: unsigned int chanspec = cmd->chanlist[async->cur_chan]; but `do_become_nonbusy()` frees `cmd->chanlist` and sets it to `NULL`. Fix the race by calling `del_timer_sync()` instead of `del_timer()` in `waveform_ai_cancel()` when not in an interrupt context. The only time `waveform_ai_cancel()` is called in an interrupt context is when it is called from the timer routine itself, via `comedi_handle_events()`. There is no longer any need for the `WAVEFORM_AI_RUNNING` flag, so get rid of it. The bug was copied from the AI subdevice to the AO when support for commands on the AO subdevice was added by commit 0cf55bbef2f9 ("staging: comedi: comedi_test: implement commands on AO subdevice"). That involves the timer routine `waveform_ao_timer()`, the comedi "cancel" routine `waveform_ao_cancel()`, and the flag `WAVEFORM_AO_RUNNING`. Fix it in the same way as for the AI subdevice. Fixes: 73e0e4dfed4c ("staging: comedi: comedi_test: fix timer lock-up") Fixes: 0cf55bbef2f9 ("staging: comedi: comedi_test: implement commands on AO subdevice") Reported-by: Éric Piel Signed-off-by: Ian Abbott Cc: # 4.4+ Cc: Éric Piel --- Needs backporting to stable kernels from 3.19.x onwards (mainly longterm release 4.1). --- drivers/staging/comedi/drivers/comedi_test.c | 46 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 4ab1866..ec5b9a2 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -56,11 +56,6 @@ #define N_CHANS 8 -enum waveform_state_bits { - WAVEFORM_AI_RUNNING, - WAVEFORM_AO_RUNNING -}; - /* Data unique to this driver */ struct waveform_private { struct timer_list ai_timer; /* timer for AI commands */ @@ -68,7 +63,6 @@ struct waveform_private { unsigned int wf_amplitude; /* waveform amplitude in microvolts */ unsigned int wf_period; /* waveform period in microseconds */ unsigned int wf_current;/* current time in waveform period */ - unsigned long state_bits; unsigned int ai_scan_period;/* AI scan period in usec */ unsigned int ai_convert_period; /* AI conversion period in usec */ struct timer_list ao_timer; /* timer for AO commands */ @@ -191,10 +185,6 @@ static void waveform_ai_timer(unsigned long arg) unsigned int nsamples; unsigned int time_increment; - /* check command is still active */ - if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits)) - return; - now = ktime_to_us(ktime_get()); nsamples = comedi_nsamples_left(s, UINT_MAX); @@ -386,11 +376,6 @@ static int waveform_ai_cmd(struct comedi_device *dev, */ devpriv->ai_timer.expires = jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1; - - /* mark command as active */ - smp_mb__before_atomic(); - set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); - smp_mb__after_atomic(); add_timer(&devpriv->ai_timer); return 0; } @@ -400,11 +385,12 @@ static int waveform_ai_cancel(struct comedi_device *dev, { struct waveform_private *devpriv = dev->private; - /* mark command as no longer active */ - clear_bit(W
[PATCH 1/6] lib: string: add function strtolower()
Add a function called strtolower() to convert strings to lower case in-place, overwriting the original string. This seems to be a recurring requirement in the kernel that is currently being solved by several duplicated implementations doing the same thing. Signed-off-by: Markus Mayer --- include/linux/string.h | 1 + lib/string.c | 14 ++ 2 files changed, 15 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 26b6f6a..aad605e 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -116,6 +116,7 @@ extern void * memchr(const void *,int,__kernel_size_t); #endif void *memchr_inv(const void *s, int c, size_t n); char *strreplace(char *s, char old, char new); +char *strtolower(char *s); extern void kfree_const(const void *x); diff --git a/lib/string.c b/lib/string.c index ed83562..6e3b560 100644 --- a/lib/string.c +++ b/lib/string.c @@ -952,3 +952,17 @@ char *strreplace(char *s, char old, char new) return s; } EXPORT_SYMBOL(strreplace); + +char *strtolower(char *s) +{ + char *p; + +if (unlikely(!s)) +return NULL; + + for (p = s; *p; p++) + *p = tolower(*p); + + return s; +} +EXPORT_SYMBOL(strtolower); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/6] staging: speakup: replace spk_strlwr() with strtolower()
After introducing generic strtolower(), spk_strlwr() is no longer needed. Signed-off-by: Markus Mayer --- drivers/staging/speakup/kobjects.c| 2 +- drivers/staging/speakup/main.c| 2 +- drivers/staging/speakup/speakup.h | 1 - drivers/staging/speakup/varhandlers.c | 12 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 528cbdc..009c0d2 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -391,7 +391,7 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, if (new_synth_name[len - 1] == '\n') len--; new_synth_name[len] = '\0'; - spk_strlwr(new_synth_name); + strtolower(new_synth_name); if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) { pr_warn("%s already in use\n", new_synth_name); } else if (synth_init(new_synth_name) != 0) { diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index 97ca4ec..3f3f254 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -2314,7 +2314,7 @@ static int __init speakup_init(void) spk_initialize_msgs(); /* Initialize arrays for i18n. */ spk_reset_default_chars(); spk_reset_default_chartab(); - spk_strlwr(synth_name); + strtolower(synth_name); spk_vars[0].u.n.high = vc->vc_cols; for (var = spk_vars; var->var_id != MAXVARS; var++) speakup_register_var(var); diff --git a/drivers/staging/speakup/speakup.h b/drivers/staging/speakup/speakup.h index df74c91..4725785 100644 --- a/drivers/staging/speakup/speakup.h +++ b/drivers/staging/speakup/speakup.h @@ -50,7 +50,6 @@ void synth_insert_next_index(int sent_num); void spk_reset_index_count(int sc); void spk_get_index_count(int *linecount, int *sentcount); int spk_set_key_info(const u_char *key_info, u_char *k_buffer); -char *spk_strlwr(char *s); char *spk_s2uchar(char *start, char *dest); int speakup_kobj_init(void); void speakup_kobj_exit(void); diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c index e1393d2..a1af222 100644 --- a/drivers/staging/speakup/varhandlers.c +++ b/drivers/staging/speakup/varhandlers.c @@ -309,18 +309,6 @@ int spk_set_mask_bits(const char *input, const int which, const int how) return 0; } -char *spk_strlwr(char *s) -{ - char *p; - - if (!s) - return NULL; - - for (p = s; *p; p++) - *p = tolower(*p); - return s; -} - char *spk_s2uchar(char *start, char *dest) { int val; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/6] lib: string: add function strtolower()
This series introduces a new generic function strtolower(), which converts strings to lowercase in-place, overwriting the original string. This kind of functionality is needed in several places in the kernel. Right now, everybody seems to be implementing their own copy of this function. So, we replace several custom "strtolower" implementations with this new library function. Another driver that also makes use of this function will be submitted upstream shortly, which prompted this whole exercise. The changes made here have been compile-tested, but not tried out, due to lack of required hardware. This series is based on v4.7-rc5. Markus Mayer (6): lib: string: add function strtolower() drm/nouveau/core: make use of new strtolower() function ACPICA: make use of new strtolower() function ACPI / device_sysfs: make use of new strtolower() function staging: speakup: replace spk_strlwr() with strtolower() iscsi-target: replace iscsi_initiatorname_tolower() with strtolower() drivers/acpi/acpica/utnonansi.c | 13 + drivers/acpi/device_sysfs.c | 4 +--- drivers/gpu/drm/nouveau/nvkm/core/firmware.c | 7 +-- drivers/staging/speakup/kobjects.c | 2 +- drivers/staging/speakup/main.c | 2 +- drivers/staging/speakup/speakup.h| 1 - drivers/staging/speakup/varhandlers.c| 12 drivers/target/iscsi/iscsi_target_nego.c | 17 + include/linux/string.h | 1 + lib/string.c | 14 ++ 10 files changed, 21 insertions(+), 52 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 5/6] staging: speakup: replace spk_strlwr() with strtolower()
Markus Mayer, on Thu 30 Jun 2016 16:50:11 -0700, wrote: > After introducing generic strtolower(), spk_strlwr() is no longer > needed. > > Signed-off-by: Markus Mayer Acked-by: Samuel Thibault > --- > drivers/staging/speakup/kobjects.c| 2 +- > drivers/staging/speakup/main.c| 2 +- > drivers/staging/speakup/speakup.h | 1 - > drivers/staging/speakup/varhandlers.c | 12 > 4 files changed, 2 insertions(+), 15 deletions(-) > > diff --git a/drivers/staging/speakup/kobjects.c > b/drivers/staging/speakup/kobjects.c > index 528cbdc..009c0d2 100644 > --- a/drivers/staging/speakup/kobjects.c > +++ b/drivers/staging/speakup/kobjects.c > @@ -391,7 +391,7 @@ static ssize_t synth_store(struct kobject *kobj, struct > kobj_attribute *attr, > if (new_synth_name[len - 1] == '\n') > len--; > new_synth_name[len] = '\0'; > - spk_strlwr(new_synth_name); > + strtolower(new_synth_name); > if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) { > pr_warn("%s already in use\n", new_synth_name); > } else if (synth_init(new_synth_name) != 0) { > diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c > index 97ca4ec..3f3f254 100644 > --- a/drivers/staging/speakup/main.c > +++ b/drivers/staging/speakup/main.c > @@ -2314,7 +2314,7 @@ static int __init speakup_init(void) > spk_initialize_msgs(); /* Initialize arrays for i18n. */ > spk_reset_default_chars(); > spk_reset_default_chartab(); > - spk_strlwr(synth_name); > + strtolower(synth_name); > spk_vars[0].u.n.high = vc->vc_cols; > for (var = spk_vars; var->var_id != MAXVARS; var++) > speakup_register_var(var); > diff --git a/drivers/staging/speakup/speakup.h > b/drivers/staging/speakup/speakup.h > index df74c91..4725785 100644 > --- a/drivers/staging/speakup/speakup.h > +++ b/drivers/staging/speakup/speakup.h > @@ -50,7 +50,6 @@ void synth_insert_next_index(int sent_num); > void spk_reset_index_count(int sc); > void spk_get_index_count(int *linecount, int *sentcount); > int spk_set_key_info(const u_char *key_info, u_char *k_buffer); > -char *spk_strlwr(char *s); > char *spk_s2uchar(char *start, char *dest); > int speakup_kobj_init(void); > void speakup_kobj_exit(void); > diff --git a/drivers/staging/speakup/varhandlers.c > b/drivers/staging/speakup/varhandlers.c > index e1393d2..a1af222 100644 > --- a/drivers/staging/speakup/varhandlers.c > +++ b/drivers/staging/speakup/varhandlers.c > @@ -309,18 +309,6 @@ int spk_set_mask_bits(const char *input, const int > which, const int how) > return 0; > } > > -char *spk_strlwr(char *s) > -{ > - char *p; > - > - if (!s) > - return NULL; > - > - for (p = s; *p; p++) > - *p = tolower(*p); > - return s; > -} > - > char *spk_s2uchar(char *start, char *dest) > { > int val; > -- > 2.7.4 > -- Samuel m'enfin, le 5 juillet, le mec vient visiter le labo... * D a marque d'une croix rouge le 5 juillet sur son agenda niarc niarc niarc cet homme va souffrir c'est donc le 5 juillet qu'il meurt d'un accident de la route écrasé par un truck muni d'un pare buffle -+- #ens-mim - repaire de terroristes -+- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/3] staging: lowmemorykiller: count anon pages only when we have swap devices
2016-06-23 16:42 GMT+08:00 Sergey Senozhatsky : > On (06/22/16 11:27), Ganesh Mahendran wrote: > [..] >> > > Signed-off-by: Ganesh Mahendran >> > > --- >> > > drivers/staging/android/lowmemorykiller.c | 12 >> > > 1 file changed, 8 insertions(+), 4 deletions(-) >> > > >> > > diff --git a/drivers/staging/android/lowmemorykiller.c >> > > b/drivers/staging/android/lowmemorykiller.c >> > > index 6da9260..1d8de47 100644 >> > > --- a/drivers/staging/android/lowmemorykiller.c >> > > +++ b/drivers/staging/android/lowmemorykiller.c >> > > @@ -73,10 +73,14 @@ static unsigned long lowmem_deathpending_timeout; >> > > static unsigned long lowmem_count(struct shrinker *s, >> > > struct shrink_control *sc) >> > > { >> > > - return global_page_state(NR_ACTIVE_ANON) + >> > > - global_page_state(NR_ACTIVE_FILE) + >> > > - global_page_state(NR_INACTIVE_ANON) + >> > > - global_page_state(NR_INACTIVE_FILE); >> > > + unsigned long freeable = global_page_state(NR_ACTIVE_FILE) + >> > > + global_page_state(NR_INACTIVE_FILE); >> > > + >> > > + if (get_nr_swap_pages() > 0) >> > > + freeable += global_page_state(NR_ACTIVE_ANON) + >> > > + global_page_state(NR_INACTIVE_ANON); >> > > + >> > > + return freeable; >> > > } >> > > >> > > static unsigned long lowmem_scan(struct shrinker *s, struct >> > > shrink_control *sc) >> > >> > Shouldn't this be advertising the amount of memory that is freeable by >> > killing the process with the highest priority oom_score_adj? It's not >> > legitimate to say it can free all anon and file memory if nothing is oom >> > killable, so this function is wrong both originally and with your patched >> > version. >> >> Yes, so should we just simply return 1 to make do_shrink_slab() go ahead? >> Then lowmem_scan() will do the real job to scan all the process. > > hm, looking at ->scan (lowmem_scan) shouldn't it return SHRINK_STOP > when it has nothing to free instead of 0? Yes, you are right. It should return SHRINK_STOP. > > -ss ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v14 net-next 1/1] hv_sock: introduce Hyper-V Sockets
On Thu, Jun 30, Olaf Hering wrote: > On Thu, Jun 30, Dexuan Cui wrote: > > > -#define AF_MAX 43 /* For now.. */ > > +#define AF_MAX 44 /* For now.. */ > > Should this patch also change the places where AF_MAX is used, > like all the arrays in net/core/sock.c? Also, there are appearently two competing changes for AF_MAX, one is yours and the other one is AF_SMC. I'm not subscribed to netdev, so its not clear which one gets applied first. Olaf. signature.asc Description: PGP signature ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel