From: Jens Axboe <jens.axboe@oracle.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Boaz Harrosh <bharrosh@panasas.com>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Linux Kernel Development <linux-kernel@vger.kernel.org>,
mingo@elte.hu
Subject: Re: [PATCH 09/10] Change table chaining layout
Date: Thu, 25 Oct 2007 11:11:40 +0200 [thread overview]
Message-ID: <20071025091140.GK5053@kernel.dk> (raw)
In-Reply-To: <200710251840.02157.rusty@rustcorp.com.au>
On Thu, Oct 25 2007, Rusty Russell wrote:
> On Wednesday 24 October 2007 01:22:55 Linus Torvalds wrote:
> > On Tue, 23 Oct 2007, Boaz Harrosh wrote:
> > > But since we do not do that, and every single API in the kernel that
> > > receives a scatterlist pointer also receives an sg_count parameter,
> > > than I do not see what is so hacky about giving that sg_count parameter
> > > to the one that needs it the most. sg_next();
> >
> > Well, I'd personally actually prefer to *not* have the count be passed
> > down explicitly, because it's just too error prone.
>
> Well, the duplication is bad, but walking lists to find the length is
> inefficient so you pass around the length as well.
>
> What irritates me more is that scatterlists aren't quite generically useful.
> The virtio code wants to join a scatterlist created by blk_rq_map_sg() with
> two others, yet it won't work because sg_chain() doesn't remove the end
> marker from the first entry.
That's a minor nit for your special purpose, we/you can change that.
> If this patch weren't already included, I'd be strongly arguing for the bio
> idea: I find the chained sg code tricksy and ugly (sorry Jens).
What is the bio idea? A bio works in essentially the same way, the only
difference is having a specific next pointer. It's still just a linked
lists of arbitrarily sized sg tables (the bio_vec arrays).
>
> To be constructive, how's this (BTW, why @arg@, I thought it was simply
> "@arg"?)
>
> ===
> Make sg_chain() a little more generic
>
> Allow chaining when the first chain already has an end marker, and
> change it to a slightly clearer semantic (the number of used entries
> in the array, not that number plus one).
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 61fdaf0..24bbc92 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -778,7 +778,7 @@ struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
> * ended up doing another loop.
> */
> if (prev)
> - sg_chain(prev, SCSI_MAX_SG_SEGMENTS, sgl);
> + sg_chain(prev, SCSI_MAX_SG_SEGMENTS-1, sgl);
What's this bit for?
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index df7ddce..c1ef145 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> @@ -147,12 +147,11 @@ static inline struct scatterlist *sg_last(struct scatterlist *sgl,
> /**
> * sg_chain - Chain two sglists together
> * @prv: First scatterlist
> - * @prv_nents: Number of entries in prv
> + * @prv_nents: Number of entries used in prv
> * @sgl: Second scatterlist
> *
> * Description:
> - * Links @prv@ and @sgl@ together, to form a longer scatterlist.
> - *
> + * @prv[@prv_nents] is used as a link to join @prv to @sgl.
> **/
> static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
> struct scatterlist *sgl)
> @@ -160,7 +159,9 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
> #ifndef ARCH_HAS_SG_CHAIN
> BUG();
> #endif
> - prv[prv_nents - 1].page_link = (unsigned long) sgl | 0x01;
> + if (prv_nents > 0)
> + prv[prv_nents - 1].page_link &= ~0x02UL;
> + prv[prv_nents].page_link = (unsigned long) sgl | 0x01;
> }
We definitely should clear any other markers, that makes sense.
--
Jens Axboe
next prev parent reply other threads:[~2007-10-25 9:13 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-22 18:10 [PATCH 00/10] SG updates Jens Axboe
2007-10-22 18:10 ` [PATCH 01/10] [SG] Add helpers for manipulating SG entries Jens Axboe
2007-10-22 18:10 ` [PATCH 02/10] [SG] Update block layer to use sg helpers Jens Axboe
2007-10-23 5:13 ` Heiko Carstens
2007-10-23 5:16 ` Jens Axboe
2007-10-23 5:42 ` [PATCH] fix ll_rw_blk.c build on s390 Heiko Carstens
2007-10-23 5:44 ` [PATCH] net: fix xfrm build - missing scatterlist.h include Heiko Carstens
2007-10-23 7:28 ` Jens Axboe
2007-10-23 14:32 ` [PATCH 02/10] [SG] Update block layer to use sg helpers John Stoffel
2007-10-22 18:10 ` [PATCH 03/10] [SG] Update crypto/ to " Jens Axboe
2007-10-22 18:10 ` [PATCH 04/10] [SG] Update drivers to use " Jens Axboe
2007-10-23 6:28 ` Heiko Carstens
2007-10-23 7:14 ` Jens Axboe
2007-10-23 7:16 ` Heiko Carstens
2007-10-22 18:10 ` [PATCH 05/10] [SG] Update fs/ " Jens Axboe
2007-10-22 18:11 ` [PATCH 06/10] [SG] Update net/ " Jens Axboe
2007-10-23 10:44 ` Christian Borntraeger
2007-10-23 10:45 ` Jens Axboe
2007-10-22 18:11 ` [PATCH 07/10] [SG] Update swiotlb " Jens Axboe
2007-10-22 18:11 ` [PATCH 08/10] [SG] Update arch/ " Jens Axboe
2007-10-22 21:10 ` Benny Halevy
2007-10-23 7:26 ` Jens Axboe
2007-10-22 18:11 ` [PATCH 09/10] Change table chaining layout Jens Axboe
2007-10-22 19:39 ` Geert Uytterhoeven
2007-10-22 19:49 ` Linus Torvalds
2007-10-22 19:52 ` Jens Axboe
2007-10-22 20:16 ` Alan Cox
2007-10-22 20:38 ` Matt Mackall
2007-10-22 20:44 ` Linus Torvalds
2007-10-22 21:43 ` Alan Cox
2007-10-22 21:47 ` Linus Torvalds
2007-10-23 0:07 ` David Miller
2007-10-23 7:18 ` Geert Uytterhoeven
2007-10-23 9:29 ` Boaz Harrosh
2007-10-23 9:41 ` Jens Axboe
2007-10-23 9:50 ` Boaz Harrosh
2007-10-23 9:55 ` Jens Axboe
2007-10-23 10:23 ` Boaz Harrosh
2007-10-23 10:29 ` Jens Axboe
2007-10-23 15:22 ` Linus Torvalds
2007-10-24 8:05 ` Jens Axboe
2007-10-24 9:03 ` Geert Uytterhoeven
2007-10-24 9:12 ` Jens Axboe
2007-10-24 13:35 ` Olivier Galibert
2007-10-24 13:38 ` Jens Axboe
2007-10-24 13:45 ` Olivier Galibert
2007-10-24 15:16 ` Linus Torvalds
2007-10-25 8:40 ` Rusty Russell
2007-10-25 9:11 ` Jens Axboe [this message]
2007-10-25 11:54 ` Rusty Russell
2007-10-26 0:03 ` Rusty Russell
2007-10-25 15:40 ` Linus Torvalds
2007-10-25 16:03 ` Benny Halevy
2007-10-26 5:01 ` Paul Mackerras
2007-10-26 14:52 ` Linus Torvalds
2007-10-26 17:28 ` Jens Axboe
2007-11-05 6:11 ` [RFC PATCH 1/2] sg_ring instead of scatterlist chaining Rusty Russell
2007-11-05 6:15 ` [RFC PATCH 2/2] sg_ring instead of scatterlist chaining in virtio Rusty Russell
2007-11-05 16:40 ` [RFC PATCH 1/2] sg_ring instead of scatterlist chaining Randy Dunlap
2007-10-23 10:33 ` [PATCH 09/10] Change table chaining layout Ingo Molnar
2007-10-23 10:56 ` Jens Axboe
2007-10-23 11:27 ` Ingo Molnar
2007-10-23 19:23 ` Geert Uytterhoeven
2007-10-23 21:46 ` Jens Axboe
2007-10-24 6:56 ` Jens Axboe
2007-10-22 21:16 ` Benny Halevy
2007-10-22 21:21 ` Jeff Garzik
2007-10-22 21:47 ` Matt Mackall
2007-10-22 22:52 ` Alan Cox
2007-10-22 23:46 ` Matt Mackall
2007-10-23 0:11 ` Jeff Garzik
2007-10-23 4:09 ` powerpc: Fix fallout from sg_page() changes Olof Johansson
2007-10-23 4:09 ` Olof Johansson
2007-10-23 4:31 ` IB/ehca: Fix sg_page() fallout Olof Johansson
2007-10-23 4:31 ` Olof Johansson
2007-10-23 5:05 ` Jens Axboe
2007-10-23 5:05 ` Jens Axboe
2007-10-23 5:54 ` Olof Johansson
2007-10-23 5:54 ` Olof Johansson
2007-10-23 7:12 ` Jens Axboe
2007-10-23 7:12 ` Jens Axboe
2007-10-23 7:13 ` powerpc: Fix fallout from sg_page() changes Jens Axboe
2007-10-23 7:13 ` Jens Axboe
2007-10-23 17:08 ` [PATCH 09/10] Change table chaining layout Boaz Harrosh
2007-10-23 18:33 ` Jens Axboe
2007-10-23 19:56 ` Andi Kleen
2007-10-23 20:20 ` Jens Axboe
2007-10-23 20:57 ` Andi Kleen
2007-10-23 21:44 ` Jens Axboe
2007-10-22 18:11 ` [PATCH 10/10] Add CONFIG_DEBUG_SG sg validation Jens Axboe
2007-10-23 14:48 ` [PATCH][SG] fix typo in ps3rom.c Arnd Bergmann
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=20071025091140.GK5053@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bharrosh@panasas.com \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@linux-foundation.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.