From: Bart Van Assche <bvanassche@acm.org>
To: Ming Lei <ming.lei@redhat.com>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
"Ewan D . Milne" <emilne@redhat.com>,
Hannes Reinecke <hare@suse.com>
Subject: Re: [PATCH 1/2] scsi: core: avoid to pre-allocate big chunk for protection meta data
Date: Tue, 23 Apr 2019 08:33:47 -0700 [thread overview]
Message-ID: <1556033627.161891.120.camel@acm.org> (raw)
In-Reply-To: <20190423103240.29864-2-ming.lei@redhat.com>
On Tue, 2019-04-23 at 18:32 +0800, Ming Lei wrote:
> +/*
> + * Size of integrity meta data size is usually small, 1 inline sg
^^^^^^^^^^^^^^
Please change this into "metadata". Mentioning "size" twice is not
useful.
> + * should cover normal cases.
> + */
> +#define SCSI_INLINE_PROT_SG_CNT 1
> +
> static struct kmem_cache *scsi_sdb_cache;
> static struct kmem_cache *scsi_sense_cache;
> static struct kmem_cache *scsi_sense_isadma_cache;
> @@ -553,12 +559,21 @@ static void scsi_uninit_cmd(struct scsi_cmnd *cmd)
> }
> }
>
> +static inline bool scsi_prot_use_inline_sg(struct scsi_cmnd *cmd)
> +{
> + if (!scsi_prot_sglist(cmd))
> + return false;
Since scsi_prot_use_inline_sg() is only called if scsi_prot_sg_count() > 0,
is the above test necessary?
> + return cmd->prot_sdb->table.sgl ==
> + (struct scatterlist *)(cmd->prot_sdb + 1);
> +}
> +
> static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
> {
> if (cmd->sdb.table.nents)
> sg_free_table_chained(&cmd->sdb.table, true);
> - if (scsi_prot_sg_count(cmd))
> - sg_free_table_chained(&cmd->prot_sdb->table, true);
> + if (scsi_prot_sg_count(cmd) && !scsi_prot_use_inline_sg(cmd))
> + sg_free_table_chained(&cmd->prot_sdb->table, false);
> }
>
> static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
> @@ -1044,9 +1059,11 @@ blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
> }
>
> ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);
> -
> - if (sg_alloc_table_chained(&prot_sdb->table, ivecs,
> - prot_sdb->table.sgl)) {
> + if (ivecs <= SCSI_INLINE_PROT_SG_CNT)
> + prot_sdb->table.nents = prot_sdb->table.orig_nents =
> + SCSI_INLINE_PROT_SG_CNT;
Please call sg_init_table() instead of open-coding it.
> + else if (sg_alloc_table_chained(&prot_sdb->table, ivecs,
> + NULL)) {
> ret = BLK_STS_RESOURCE;
> goto out_free_sgtables;
> }
Bart.
next prev parent reply other threads:[~2019-04-23 15:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-23 10:32 [PATCH 0/2] scis: core: avoid big pre-allocation for sg list Ming Lei
2019-04-23 10:32 ` [PATCH 1/2] scsi: core: avoid to pre-allocate big chunk for protection meta data Ming Lei
2019-04-23 15:33 ` Bart Van Assche [this message]
2019-04-24 0:46 ` Ming Lei
2019-04-23 10:32 ` [PATCH 2/2] scsi: core: avoid to pre-allocate big chunk for sg list Ming Lei
2019-04-23 15:37 ` Bart Van Assche
2019-04-24 7:52 ` Ming Lei
2019-04-24 15:24 ` James Bottomley
2019-04-24 15:32 ` Bart Van Assche
2019-04-24 15:37 ` Jens Axboe
2019-04-24 15:49 ` James Bottomley
2019-04-24 16:09 ` Bart Van Assche
2019-04-24 16:17 ` James Bottomley
2019-04-24 5:53 ` Christoph Hellwig
2019-04-24 8:41 ` Ming Lei
2019-04-24 14:38 ` Christoph Hellwig
2019-04-25 0:45 ` Ming Lei
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=1556033627.161891.120.camel@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=emilne@redhat.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
/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.