mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Jens Axboe" <jens.axboe@oracle.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/12] i386 sg: add support for chaining scatterlists
Date: Thu, 10 May 2007 18:30:19 +0530	[thread overview]
Message-ID: <a781481a0705100600n3258564r96f44cacce00c372@mail.gmail.com> (raw)
In-Reply-To: <11787972373410-git-send-email-jens.axboe@oracle.com>

Hi Jens,

On 5/10/07, Jens Axboe <jens.axboe@oracle.com> wrote:
> The core of the patch - allow the last sg element in a scatterlist
> table to point to the start of a new table. We overload the LSB of
> the page pointer to indicate whether this is a valid sg entry, or
> merely a link to the next list.
>
> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> ---
>  include/asm-i386/scatterlist.h |    2 +
>  include/linux/scatterlist.h    |   52 ++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 52 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-i386/scatterlist.h b/include/asm-i386/scatterlist.h
> index d7e45a8..bd5164a 100644
> --- a/include/asm-i386/scatterlist.h
> +++ b/include/asm-i386/scatterlist.h
> @@ -10,6 +10,8 @@ struct scatterlist {
>      unsigned int       length;
>  };
>
> +#define ARCH_HAS_SG_CHAIN
> +
>  /* These macros should be used after a pci_map_sg call has been done
>   * to get bus addresses of each of the SG entries and their lengths.
>   * You should only work with the number of sg entries pci_map_sg
> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
> index bed5ab4..fa2dc1c 100644
> --- a/include/linux/scatterlist.h
> +++ b/include/linux/scatterlist.h
> [...]
> +/*
> + * We could improve this by passing in the maximum size of an sglist, so
> + * we could jump directly to the last table. That would eliminate this
> + * (potentially) lengthy scan.
> + */
> +static inline struct scatterlist *sg_last(struct scatterlist *sgl,
> +                                         unsigned int nents)
> +{
> +#ifdef ARCH_HAS_SG_CHAIN
> +       struct scatterlist *ret = &sgl[nents - 1];
> +#else
> +       struct scatterlist *sg, *ret = NULL;
> +       int i;
> +
> +       for_each_sg(sgl, sg, nents, i)
> +               ret = sg;
> +
> +#endif
> +       return ret;
> +}
> +
> +/*
> + * Chain previous sglist to this one
> + */
> +static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
> +                           struct scatterlist *sgl)
> +{
> +#ifndef ARCH_HAS_SG_CHAIN
> +       BUG();
> +#endif
> +       prv[prv_nents - 1].page = (struct page *) ((unsigned long) sgl | 0x01);
> +}
> +
>  #endif /* _LINUX_SCATTERLIST_H */

(Style triviality)

In include/linux/scatterlist.h, why not simply:

#ifdef ARCH_HAS_SG_CHAIN

> +/*
> + * We could improve this by passing in the maximum size of an sglist, so
> + * we could jump directly to the last table. That would eliminate this
> + * (potentially) lengthy scan.
> + */
> +static inline struct scatterlist *sg_last(struct scatterlist *sgl,
> +                                         unsigned int nents)
> +{
> +       struct scatterlist *ret = &sgl[nents - 1];
> +       return ret;
> +}
> +
> +/*
> + * Chain previous sglist to this one
> + */
> +static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
> +                           struct scatterlist *sgl)
> +{
> +       prv[prv_nents - 1].page = (struct page *) ((unsigned long) sgl | 0x01);
> +}

#else

> +/*
> + * We could improve this by passing in the maximum size of an sglist, so
> + * we could jump directly to the last table. That would eliminate this
> + * (potentially) lengthy scan.
> + */
> +static inline struct scatterlist *sg_last(struct scatterlist *sgl,
> +                                         unsigned int nents)
> +{
> +       struct scatterlist *sg, *ret = NULL;
> +       int i;
> +
> +       for_each_sg(sgl, sg, nents, i)
> +               ret = sg;
> +
> +       return ret;
> +}
> +
> +/*
> + * Chain previous sglist to this one
> + */
> +static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
> +                           struct scatterlist *sgl)
> +{
> +       BUG();
> +}

#endif /* ARCH_HAS_SG_CHAIN */

Similar to most of the other headers I've seen, and avoids multiple
usage if #ifdef / #ifndef.

  reply	other threads:[~2007-05-10 13:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-10 11:40 [PATCH 0/12] Chaining sg lists for bio IO commands v4 Jens Axboe
2007-05-10 11:40 ` [PATCH 1/12] crypto: don't pollute the global namespace with sg_next() Jens Axboe
2007-05-10 13:55   ` Benny Halevy
2007-05-10 21:37     ` Jens Axboe
2007-05-11  5:20       ` Benny Halevy
2007-05-12  2:34         ` Herbert Xu
2007-05-10 11:40 ` [PATCH 2/12] Add sg helpers for iterating over a scatterlist table Jens Axboe
2007-05-10 11:40 ` [PATCH 3/12] libata: convert to using sg helpers Jens Axboe
2007-05-10 11:40 ` [PATCH 4/12] block: " Jens Axboe
2007-05-10 11:40 ` [PATCH 5/12] scsi: " Jens Axboe
2007-05-10 11:40 ` [PATCH 6/12] i386 dma_map_sg: " Jens Axboe
2007-05-10 11:40 ` [PATCH 7/12] i386 sg: add support for chaining scatterlists Jens Axboe
2007-05-10 13:00   ` Satyam Sharma [this message]
2007-05-10 13:23   ` Satyam Sharma
2007-05-10 11:40 ` [PATCH 8/12] x86-64: update iommu/dma mapping functions to sg helpers Jens Axboe
2007-05-10 13:48   ` Benny Halevy
2007-05-10 21:38     ` Jens Axboe
2007-05-21  6:32     ` Jens Axboe
2007-05-21  7:09       ` Benny Halevy
2007-05-21  7:13         ` Jens Axboe
2007-05-10 11:40 ` [PATCH 9/12] x86-64: enable sg chaining Jens Axboe
2007-05-10 11:40 ` [PATCH 10/12] scsi: simplify scsi_free_sgtable() Jens Axboe
2007-05-10 11:40 ` [PATCH 11/12] SCSI: support for allocating large scatterlists Jens Axboe
2007-05-10 11:40 ` [PATCH 12/12] ll_rw_blk: temporarily enable max_segments tweaking Jens Axboe

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=a781481a0705100600n3258564r96f44cacce00c372@mail.gmail.com \
    --to=satyam.sharma@gmail.com \
    --cc=jens.axboe@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome