Skip to content

scatterlist: add new capabilities

Douglas Gilbert linux-block linux-rdma linux-scsi lkml target-devel 7 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest4 patches 16 repliesIn review
  2. v54 patches 5 repliesSuperseded
  3. v4 posting 2/24 patches 0 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v4 posting 1/24 patches0 repliesSuperseded
v34 patches6 repliesSuperseded
v24 patches1 replySuperseded
v14 patches2 repliesSuperseded

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4sgl_alloc_order: remove 4 GiB limit, sgl_free() warninginclude/linux/scatterlist.h lib/scatterlist.c+11 -1113 replies
2/4scatterlist: add sgl_copy_sgl() functioninclude/linux/scatterlist.h lib/scatterlist.c+78 -00 replies
3/4scatterlist: add sgl_compare_sgl() functioninclude/linux/scatterlist.h lib/scatterlist.c+117 -03 replies
4/4scatterlist: add sgl_memset()include/linux/scatterlist.h lib/scatterlist.c+62 -370 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchBodo StroesserDavid Disseldorp
1/4R-b
2/4R-b
3/4R-b R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH v6 0/4] scatterlist: add new capabilities

Scatter-gather lists (sgl_s) are frequently used as data carriers in the block layer. For example the SCSI and NVMe subsystems interchange data with the block layer using sgl_s. The sgl API is declared in <linux/scatterlist.h>

The author has extended these transient sgl use cases to a store (i.e. a ramdisk) in the scsi_debug driver. Other new potential uses of sgl_s could be for the target subsystem. When this extra step is taken, the need to copy between sgl_s becomes apparent. The patchset adds sgl_copy_sgl(), sgl_compare_sgl() and sgl_memset().

The existing sgl_alloc_order() function can be seen as a replacement for vmalloc() for large, long-term allocations. For what seems like no good reason, sgl_alloc_order() currently restricts its total allocation to less than or equal to 4 GiB. vmalloc() has no such restriction.

Changes since v5 [posted 20201228]:
- incorporate review requests from Jason Gunthorpe
- replace integer overflow detection code in sgl_alloc_order() with a pre-condition statement
- rebase on lk 5.11.0-rc4

Changes since v4 [posted 20201105]:
- rebase on lk 5.10.0-rc2

Changes since v3 [posted 20201019]:
- re-instate check on integer overflow of nent calculation in sgl_alloc_order(). Do it in such a way as to not limit the overall sgl size to 4 GiB
- introduce sgl_compare_sgl_idx() helper function that, if requested and if a miscompare is detected, will yield the byte index of the first miscompare.
- add Reviewed-by tags from Bodo Stroesser
- rebase on lk 5.10.0-rc2 [was on lk 5.9.0]

Changes since v2 [posted 20201018]:
- remove unneeded lines from sgl_memset() definition.
- change sg_zero_buffer() to call sgl_memset() as the former is a subset.

Changes since v1 [posted 20201016]:
- Bodo Stroesser pointed out a problem with the nesting of kmap_atomic() [called via sg_miter_next()] and kunmap_atomic() calls [called via sg_miter_stop()] and proposed a solution that simplifies the previous code.

- the new implementation of the three functions has shorter periods when pre-emption is disabled (but has more them). This should make operations on large sgl_s more pre-emption "friendly" with a relatively small performance hit.

- sgl_memset return type changed from void to size_t and is the number of bytes actually (over)written. That number is needed anyway internally so may as well return it as it may be useful to the caller.

This patchset is against lk 5.11.0-rc4

Douglas Gilbert (4):
sgl_alloc_order: remove 4 GiB limit, sgl_free() warning
scatterlist: add sgl_copy_sgl() function
scatterlist: add sgl_compare_sgl() function
scatterlist: add sgl_memset()

 include/linux/scatterlist.h |  33 ++++-
 lib/scatterlist.c           | 253 +++++++++++++++++++++++++++++++-----
 2 files changed, 253 insertions(+), 33 deletions(-)
Signature · 1 line
2.25.1