Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2115164pxb; Mon, 18 Jan 2021 08:35:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJXU2NcBsoyTTFRX6K5h4cmUvym+OrEQLcYW8zqiI2MygD9h9aB6BkzJUcluZLekuXiYaW X-Received: by 2002:a50:e78b:: with SMTP id b11mr218300edn.165.1610987725901; Mon, 18 Jan 2021 08:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610987725; cv=none; d=google.com; s=arc-20160816; b=UtQYikN5FxyBS9IgGVatrgEp5k8lVoVt/UlNB8kaZHe1WVE7bWlmuuKs5f0VejcI2J ZJumn79ePenAzrjyFYnfR2DshIlXbYgS426Qp6LEKuhTICAXcbGBUMssWTzk9QnEJbwz GesO/ngc4AfE9H5io2NrvSaTInvb1ep565E+TysyU8IFVXomKr3cweDFUr+jmcQlZynT L6x5qKtbSbBJE3ukRZh2FUuFaGOAkIbpuOxdatPwswl/Y1Qq7yuj3YcV7AMrKxmSOFdO oUOkMDqGE/FFeFd6IFIxQH9dQb9AQbYZ0g0fgHRb2zb+75jca4Ma4u/muruZwf91KvZU IKgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=npihOg3vEhKk2qRWoF9FdsDkg1RXH0msyZiee+fCZtA=; b=KWU/aammVgOV1OYl2uYe3V0dYa4E4VMo587dj674thwgXEUJfYpi77WcbzjJy0qqfK Fdo6Lg5OtEK4WgRGhMtffxKio69b1kMtp8mAAywfFV4ff27ZnV2Jalv7ztxSUP/ALmTh F5xdkCLUcoxzpLDpqrPKJ9QAkcSx6hH26KRtVsAYgVr6eC3tf9zhIKOGFmpX5UyDqRDs wB43djaQxOTQ0xydMchNvZDNiLDLaB/4CPb3tqFGgE+/sDIBHda2nG6Zj+QoX206ud0f /+uiwsu1uJsf19Y4FUw9CmsnViD/7Y0cko65k880+u50jfOWeYy4cLVtSN1IDtKVl22m jDug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b2si6091450ejh.264.2021.01.18.08.34.51; Mon, 18 Jan 2021 08:35:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406785AbhARQcC (ORCPT + 99 others); Mon, 18 Jan 2021 11:32:02 -0500 Received: from smtp.infotech.no ([82.134.31.41]:45726 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406723AbhARQbH (ORCPT ); Mon, 18 Jan 2021 11:31:07 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 114222042B4; Mon, 18 Jan 2021 17:30:22 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fP6VqsNWXjil; Mon, 18 Jan 2021 17:30:14 +0100 (CET) Received: from xtwo70.bingwo.ca (host-104-157-204-209.dyn.295.ca [104.157.204.209]) by smtp.infotech.no (Postfix) with ESMTPA id E1CBB20416A; Mon, 18 Jan 2021 17:30:10 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, target-devel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, bostroesser@gmail.com, ddiss@suse.de, bvanassche@acm.org, jgg@ziepe.ca Subject: [PATCH v6 0/4] scatterlist: add new capabilities Date: Mon, 18 Jan 2021 11:30:02 -0500 Message-Id: <20210118163006.61659-1-dgilbert@interlog.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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(-) -- 2.25.1