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:   Mon, 28 Oct 2019 17:24:12 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Davidlohr Bueso <dave@...olabs.net>
Cc:     eric@...olt.net, wahrenst@....net, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex
 with spinlock

On Mon, Oct 28, 2019 at 08:53:54AM -0700, Davidlohr Bueso wrote:
> Cc devel@...verdev.osuosl.org
> 
> On Sun, 27 Oct 2019, Bueso wrote:
> 
> > There seems no need to be using a semaphore, or a sleeping lock
> > in the first place: critical region is extremely short, does not
> > call into any blocking calls and furthermore lock and unlocking
> > operations occur in the same context.
> > 
> > Get rid of another semaphore user by replacing it with a spinlock.
> > 
> > Signed-off-by: Davidlohr Bueso <dave@...olabs.net>
> > ---
> > This is in an effort to further reduce semaphore users in the kernel.
> > 
> > .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> > index 8dc730cfe7a6..710d21654128 100644
> > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> > @@ -63,7 +63,7 @@ static char *g_free_fragments;
> > static struct semaphore g_free_fragments_sema;
> > static struct device *g_dev;
> > 
> > -static DEFINE_SEMAPHORE(g_free_fragments_mutex);
> > +static DEFINE_SPINLOCK(g_free_fragments_lock);
> > 
> > static irqreturn_t
> > vchiq_doorbell_irq(int irq, void *dev_id);
> > @@ -528,11 +528,11 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
> > 
> > 		WARN_ON(g_free_fragments == NULL);
> > 
> > -		down(&g_free_fragments_mutex);
> > +		spin_lock(&g_free_fragments_lock);
> > 		fragments = g_free_fragments;
> > 		WARN_ON(fragments == NULL);
> > 		g_free_fragments = *(char **) g_free_fragments;
> > -		up(&g_free_fragments_mutex);
> > +		spin_unlock(&g_free_fragments_lock);
> > 		pagelist->type = PAGELIST_READ_WITH_FRAGMENTS +
> > 			(fragments - g_fragments_base) / g_fragments_size;
> > 	}
> > @@ -591,10 +591,10 @@ free_pagelist(struct vchiq_pagelist_info *pagelistinfo,
> > 			kunmap(pages[num_pages - 1]);
> > 		}
> > 
> > -		down(&g_free_fragments_mutex);
> > +		spin_lock(&g_free_fragments_lock);
> > 		*(char **)fragments = g_free_fragments;
> > 		g_free_fragments = fragments;
> > -		up(&g_free_fragments_mutex);
> > +		spin_unlock(&g_free_fragments_lock);
> > 		up(&g_free_fragments_sema);
> > 	}
> > 
> > -- 
> > 2.16.4
> > 

This is obviously not in a format I can apply it in :(

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ