lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 2 Aug 2019 15:02:17 -0400
From:   Branden Bonaby <brandonbonaby94@...il.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>
Cc:     kys@...rosoft.com, haiyangz@...rosoft.com, sthemmin@...rosoft.com,
        sashal@...nel.org, linux-hyperv@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] drivers: hv: vmbus: Introduce latency testing

On Fri, Aug 02, 2019 at 09:32:59AM +0200, Vitaly Kuznetsov wrote:
> Branden Bonaby <brandonbonaby94@...il.com> writes:
> 
> > Introduce user specified latency in the packet reception path.
> >
> > Signed-off-by: Branden Bonaby <brandonbonaby94@...il.com>
> > ---
> >  drivers/hv/connection.c  |  5 +++++
> >  drivers/hv/ring_buffer.c | 10 ++++++++++
> >  include/linux/hyperv.h   | 14 ++++++++++++++
> >  3 files changed, 29 insertions(+)
> >
> > diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
> > index 09829e15d4a0..2a2c22f5570e 100644
> > --- a/drivers/hv/connection.c
> > +++ b/drivers/hv/connection.c
> > @@ -354,9 +354,14 @@ void vmbus_on_event(unsigned long data)
> >  {
> >  	struct vmbus_channel *channel = (void *) data;
> >  	unsigned long time_limit = jiffies + 2;
> > +	struct vmbus_channel *test_channel = !channel->primary_channel ?
> > +						channel :
> > +						channel->primary_channel;
> >  
> >  	trace_vmbus_on_event(channel);
> >  
> > +	if (unlikely(test_channel->fuzz_testing_buffer_delay > 0))
> > +		udelay(test_channel->fuzz_testing_buffer_delay);
> >  	do {
> >  		void (*callback_fn)(void *);
> >  
> > diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
> > index 9a03b163cbbd..d7627c9023d6 100644
> > --- a/drivers/hv/ring_buffer.c
> > +++ b/drivers/hv/ring_buffer.c
> > @@ -395,7 +395,12 @@ struct vmpacket_descriptor *hv_pkt_iter_first(struct vmbus_channel *channel)
> >  {
> >  	struct hv_ring_buffer_info *rbi = &channel->inbound;
> >  	struct vmpacket_descriptor *desc;
> > +	struct vmbus_channel *test_channel = !channel->primary_channel ?
> > +						channel :
> > +						channel->primary_channel;
> >  
> > +	if (unlikely(test_channel->fuzz_testing_message_delay > 0))
> > +		udelay(test_channel->fuzz_testing_message_delay);
> >  	if (hv_pkt_iter_avail(rbi) < sizeof(struct vmpacket_descriptor))
> >  		return NULL;
> >  
> > @@ -420,7 +425,12 @@ __hv_pkt_iter_next(struct vmbus_channel *channel,
> >  	struct hv_ring_buffer_info *rbi = &channel->inbound;
> >  	u32 packetlen = desc->len8 << 3;
> >  	u32 dsize = rbi->ring_datasize;
> > +	struct vmbus_channel *test_channel = !channel->primary_channel ?
> > +						channel :
> > +						channel->primary_channel;
> 
> This pattern is repeated 3 times so a define is justified. I would also
> reversed the logic:
> 
>    test_channel = channel->primary_channel ? channel->primary_channel : channel;
> 
> >  
> > +	if (unlikely(test_channel->fuzz_testing_message_delay > 0))
> > +		udelay(test_channel->fuzz_testing_message_delay);
> 
> unlikely() is good but if it was under #ifdef it would've been even better.
> 
> >  	/* bump offset to next potential packet */
> -- 
> Vitaly

Makes sense, I'll address the repeated code and will change the way I
handled that if statement. Using an ifdef CONFIG_HYPERV_TESTING
seems like a good thing to add in here like you suggested.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ