All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@redhat.com>
To: Olivier Galibert <galibert@pobox.com>,
	linux-kernel@vger.kernel.org, alan@redhat.com
Subject: Re: [PATCH] isicom: Fix buffer allocation
Date: Tue, 29 Apr 2008 11:59:17 -0400	[thread overview]
Message-ID: <20080429155917.GD27202@devserv.devel.redhat.com> (raw)
In-Reply-To: <20080429152607.GA40409@dspnet.fr.eu.org>

On Tue, Apr 29, 2008 at 05:26:07PM +0200, Olivier Galibert wrote:
> > @@ -813,15 +813,13 @@
> >  		return 0;
> >  	if (!port->xmit_buf) {
> >  		/* Relies on BKL */
> > +		unsigned long page  = get_zeroed_page(GFP_KERNEL);
> > +		if (page == 0)
> >  			return -ENOMEM;
> > +		if (port->xmit_buf)
> > +			free_page(page);
> > +		else
> > +			port->xmit_buf = (unsigned char *) page;
> >  	}
> 
> 
> Still looks rather strange.  An if(x) inside an if(!x) ?

The joys of parallelism. The serial drivers mostly do this because they
are using the BKL for open/close paths being a bit prehistoric (its on
the hit list ;))

CPU #1

	open
	port->xmit_buf == NULL
	get_zeroed_page [Can sleep dropping BKL]

CPU #2

	get_zeroed_page
	port->xmit_buf == NULL
		port->xmit_buf = page

CPU #1

	port->xmit_buf != NULL
		free page

A fine example of why proper locking is good ;)


      reply	other threads:[~2008-04-29 16:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-29 13:17 [PATCH] isicom: Fix buffer allocation Alan Cox
2008-04-29 15:26 ` Olivier Galibert
2008-04-29 15:59   ` Alan Cox [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080429155917.GD27202@devserv.devel.redhat.com \
    --to=alan@redhat.com \
    --cc=galibert@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.