Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1692004

Re: [PATCH v5 1/1] KVM: trigger uevents when creating or destroying a VM

From Radim Krčmář <rkrcmar@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v5 1/1] KVM: trigger uevents when creating or destroying a VM
Date 2017-07-19 18:30 +0200
Message-ID <u501j-2Gh-1@gated-at.bofh.it> (permalink)
References <u2sds-1H6-19@gated-at.bofh.it> <u2sds-1H6-23@gated-at.bofh.it> <u4gBb-6Zb-1@gated-at.bofh.it> <u4h4d-7oe-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


2017-07-17 18:27+0200, Claudio Imbrenda:
> On Mon, 17 Jul 2017 17:53:51 +0200
> David Hildenbrand <david@redhat.com> wrote:
> > > +		tmp = strchrnul(p + 1, '-');> +
> > > *tmp = '\0';
> > > +		add_uevent_var(env, "PID=%s", p);

When we're at it ... PID exists regardless of debugfs, so it would be
nice to provide it unconditionally.
(This interface looks like it was added to discourage the use of debugfs
 directory notifier in simple cases.)

I guess we cannot use task_pid_nr(current) on the KVM_EVENT_DESTROY_VM
path, so saving the PID in struct kvm would be better, IMO (it wastes
memory with larger number of VMs, but the code is harder to break).

> > > +			tmp = dentry_path_raw(kvm->debugfs_dentry,
> > > +					      pathbuf + len,
> > > +					      PATH_MAX - len);
> > > +			if (!IS_ERR(tmp)) {  
> > 
> > Why not
> > 
> > tmp = dentry_path_raw(kvm->debugfs_dentry, pathbuf, PATH_MAX);
> > if (!IS_ERR(tmp)) {
> > 	add_uevent_var(env, "STATS_PATH=s", tmp);
> > }
> > 
> > and avoid len / pvar / memcpy? And keep internal env size checking
> > consistent.
> 
> that would be true, but then we would copy the buffer with the path
> twice, once for dentry_path_raw and once for add_uevent_var.
> 
> the env size is consistent, since that would count the bytes
> effectively present in the buffer, and note that kobject_uevent_env only
> wants a char**, no length, so there are no consistency issues. 
> 
> I agree that your solution looks better (and I had actually considered
> implementing it like that initially), but it can potentially be slower.
> I don't really have any strong preference.
> 
> Paolo: which solution do you like the most? 

I slightly prefer the simpler version as performance of the path is not
that critical.

Please note that the original patch is already in 4.13 (it was ok and my
nitpicking would just make it miss the merge window :]), so the code
improvements need to be a new patch,

thanks.

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH v5 1/1] KVM: trigger uevents when creating or destroying  a VM Radim Krčmář <rkrcmar@redhat.com> - 2017-07-19 18:30 +0200

csiph-web