From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v2 01/21] scatterlist: Introduce sg_map helper functions Date: Wed, 26 Apr 2017 09:44:16 +0200 Message-ID: <20170426074416.GA7936@lst.de> References: <1493144468-22493-1-git-send-email-logang@deltatee.com> <1493144468-22493-2-git-send-email-logang@deltatee.com> Reply-To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Sender: open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Content-Disposition: inline In-Reply-To: <1493144468-22493-2-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , To: Logan Gunthorpe Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, megaraidlinux.pdl-dY08KVG/lbpWk0Htik3J/w@public.gmane.org, sparmaintainer-GLv8BlqOqDDQT0dZR+AlfA@public.gmane.org, devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org, target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Jens Axboe , Greg Kroah-Hartman , Dan Williams , Ross Zwisler , Matthew Wilcox , Sumit Semwal Stephen Bates List-Id: dm-devel.ids On Tue, Apr 25, 2017 at 12:20:48PM -0600, Logan Gunthorpe wrote: > This patch introduces functions which kmap the pages inside an sgl. > These functions replace a common pattern of kmap(sg_page(sg)) that is > used in more than 50 places within the kernel. >=20 > The motivation for this work is to eventually safely support sgls that > contain io memory. In order for that to work, any access to the contents > of an iomem SGL will need to be done with iomemcpy or hit some warning. > (The exact details of how this will work have yet to be worked out.) I think we'll at least need a draft of those to make sense of these patches. Otherwise they just look very clumsy. > + * Use this function to map a page in the scatterlist at the specified > + * offset. sg->offset is already added for you. Note: the semantics of > + * this function are that it may fail. Thus, its output should be chec= ked > + * with IS_ERR and PTR_ERR. Otherwise, a pointer to the specified offs= et > + * in the mapped page is returned. > + * > + * Flags can be any of: > + * * SG_KMAP - Use kmap to create the mapping > + * * SG_KMAP_ATOMIC - Use kmap_atomic to map the page atommically. > + * Thus, the rules of that function apply: the > + * cpu may not sleep until it is unmaped. > + * * SG_MAP_MUST_NOT_FAIL - Indicate that sg_map must not fail. > + * If it does, it will issue a BUG_ON instead. > + * This is intended for legacy code only, it > + * is not to be used in new code. I'm sorry but this API is just a trainwreck. Right now we have the nice little kmap_atomic API, which never fails and has a very nice calling convention where we just pass back the return address, but does not support sleeping inside the critical section. And kmap, wh=D1=96ch may fail and requires the original page to be passed back. Anything that mixes these two concepts up is simply a non-starter. --=20 You received this message because you are subscribed to the Google Groups "= open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org Visit this group at https://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v2 01/21] scatterlist: Introduce sg_map helper functions Date: Wed, 26 Apr 2017 09:44:16 +0200 Message-ID: <20170426074416.GA7936@lst.de> References: <1493144468-22493-1-git-send-email-logang@deltatee.com> <1493144468-22493-2-git-send-email-logang@deltatee.com> Reply-To: open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-crypto-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org, linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, megaraidlinux.pdl-dY08KVG/lbpWk0Htik3J/w@public.gmane.org, sparmaintainer-GLv8BlqOqDDQT0dZR+AlfA@public.gmane.org, devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org, target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Jens Axboe , Greg Kroah-Hartman , Dan Williams , Ross Zwisler , Matthew Wilcox , Sumit Semwal , Stephen Bates Return-path: Sender: open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Content-Disposition: inline In-Reply-To: <1493144468-22493-2-git-send-email-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org> List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , List-Id: linux-crypto.vger.kernel.org On Tue, Apr 25, 2017 at 12:20:48PM -0600, Logan Gunthorpe wrote: > This patch introduces functions which kmap the pages inside an sgl. > These functions replace a common pattern of kmap(sg_page(sg)) that is > used in more than 50 places within the kernel. >=20 > The motivation for this work is to eventually safely support sgls that > contain io memory. In order for that to work, any access to the contents > of an iomem SGL will need to be done with iomemcpy or hit some warning. > (The exact details of how this will work have yet to be worked out.) I think we'll at least need a draft of those to make sense of these patches. Otherwise they just look very clumsy. > + * Use this function to map a page in the scatterlist at the specified > + * offset. sg->offset is already added for you. Note: the semantics of > + * this function are that it may fail. Thus, its output should be chec= ked > + * with IS_ERR and PTR_ERR. Otherwise, a pointer to the specified offs= et > + * in the mapped page is returned. > + * > + * Flags can be any of: > + * * SG_KMAP - Use kmap to create the mapping > + * * SG_KMAP_ATOMIC - Use kmap_atomic to map the page atommically. > + * Thus, the rules of that function apply: the > + * cpu may not sleep until it is unmaped. > + * * SG_MAP_MUST_NOT_FAIL - Indicate that sg_map must not fail. > + * If it does, it will issue a BUG_ON instead. > + * This is intended for legacy code only, it > + * is not to be used in new code. I'm sorry but this API is just a trainwreck. Right now we have the nice little kmap_atomic API, which never fails and has a very nice calling convention where we just pass back the return address, but does not support sleeping inside the critical section. And kmap, wh=D1=96ch may fail and requires the original page to be passed back. Anything that mixes these two concepts up is simply a non-starter. --=20 You received this message because you are subscribed to the Google Groups "= open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org Visit this group at https://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from newverein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 53DF921951C86 for ; Wed, 26 Apr 2017 00:44:19 -0700 (PDT) Date: Wed, 26 Apr 2017 09:44:16 +0200 From: Christoph Hellwig Subject: Re: [PATCH v2 01/21] scatterlist: Introduce sg_map helper functions Message-ID: <20170426074416.GA7936@lst.de> References: <1493144468-22493-1-git-send-email-logang@deltatee.com> <1493144468-22493-2-git-send-email-logang@deltatee.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1493144468-22493-2-git-send-email-logang@deltatee.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Logan Gunthorpe Cc: dri-devel@lists.freedesktop.org, dm-devel@redhat.com, target-devel@vger.kernel.org, Christoph Hellwig , devel@driverdev.osuosl.org, "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-nvdimm@lists.01.org, linux-rdma@vger.kernel.org, Sumit Semwal , open-iscsi@googlegroups.com, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, sparmaintainer@unisys.com, linux-raid@vger.kernel.org, megaraidlinux.pdl@broadcom.com, Jens Axboe , "Martin K. Petersen" , netdev@vger.kernel.org, Matthew Wilcox , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Greg Kroah-Hartman List-ID: T24gVHVlLCBBcHIgMjUsIDIwMTcgYXQgMTI6MjA6NDhQTSAtMDYwMCwgTG9nYW4gR3VudGhvcnBl IHdyb3RlOgo+IFRoaXMgcGF0Y2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W50aW9uIHdo ZXJlIHdlIGp1c3QgcGFzcyBiYWNrIHRoZSByZXR1cm4gYWRkcmVzcywgYnV0IGRvZXMKbm90IHN1 cHBvcnQgc2xlZXBpbmcgaW5zaWRlIHRoZSBjcml0aWNhbCBzZWN0aW9uLgoKQW5kIGttYXAsIHdo 0ZZjaCBtYXkgZmFpbCBhbmQgcmVxdWlyZXMgdGhlIG9yaWdpbmFsIHBhZ2UgdG8gYmUgcGFzc2Vk CmJhY2suICBBbnl0aGluZyB0aGF0IG1peGVzIHRoZXNlIHR3byBjb25jZXB0cyB1cCBpcyBzaW1w bHkgYSBub24tc3RhcnRlci4KX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX18KTGludXgtbnZkaW1tIG1haWxpbmcgbGlzdApMaW51eC1udmRpbW1AbGlzdHMuMDEu b3JnCmh0dHBzOi8vbGlzdHMuMDEub3JnL21haWxtYW4vbGlzdGluZm8vbGludXgtbnZkaW1tCg== From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from verein.lst.de ([213.95.11.211]:39343 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1432475AbdDZHoU (ORCPT ); Wed, 26 Apr 2017 03:44:20 -0400 Date: Wed, 26 Apr 2017 09:44:16 +0200 From: Christoph Hellwig To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-raid@vger.kernel.org, linux-mmc@vger.kernel.org, linux-nvdimm@lists.01.org, linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com, megaraidlinux.pdl@broadcom.com, sparmaintainer@unisys.com, devel@driverdev.osuosl.org, target-devel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, dm-devel@redhat.com, Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Jens Axboe , Greg Kroah-Hartman , Dan Williams , Ross Zwisler , Matthew Wilcox , Sumit Semwal , Stephen Bates Subject: Re: [PATCH v2 01/21] scatterlist: Introduce sg_map helper functions Message-ID: <20170426074416.GA7936@lst.de> References: <1493144468-22493-1-git-send-email-logang@deltatee.com> <1493144468-22493-2-git-send-email-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1493144468-22493-2-git-send-email-logang@deltatee.com> Sender: linux-media-owner@vger.kernel.org List-ID: On Tue, Apr 25, 2017 at 12:20:48PM -0600, Logan Gunthorpe wrote: > This patch introduces functions which kmap the pages inside an sgl. > These functions replace a common pattern of kmap(sg_page(sg)) that is > used in more than 50 places within the kernel. > > The motivation for this work is to eventually safely support sgls that > contain io memory. In order for that to work, any access to the contents > of an iomem SGL will need to be done with iomemcpy or hit some warning. > (The exact details of how this will work have yet to be worked out.) I think we'll at least need a draft of those to make sense of these patches. Otherwise they just look very clumsy. > + * Use this function to map a page in the scatterlist at the specified > + * offset. sg->offset is already added for you. Note: the semantics of > + * this function are that it may fail. Thus, its output should be checked > + * with IS_ERR and PTR_ERR. Otherwise, a pointer to the specified offset > + * in the mapped page is returned. > + * > + * Flags can be any of: > + * * SG_KMAP - Use kmap to create the mapping > + * * SG_KMAP_ATOMIC - Use kmap_atomic to map the page atommically. > + * Thus, the rules of that function apply: the > + * cpu may not sleep until it is unmaped. > + * * SG_MAP_MUST_NOT_FAIL - Indicate that sg_map must not fail. > + * If it does, it will issue a BUG_ON instead. > + * This is intended for legacy code only, it > + * is not to be used in new code. I'm sorry but this API is just a trainwreck. Right now we have the nice little kmap_atomic API, which never fails and has a very nice calling convention where we just pass back the return address, but does not support sleeping inside the critical section. And kmap, whіch may fail and requires the original page to be passed back. Anything that mixes these two concepts up is simply a non-starter. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1952530AbdDZHo1 (ORCPT ); Wed, 26 Apr 2017 03:44:27 -0400 Received: from verein.lst.de ([213.95.11.211]:39343 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1432475AbdDZHoU (ORCPT ); Wed, 26 Apr 2017 03:44:20 -0400 Date: Wed, 26 Apr 2017 09:44:16 +0200 From: Christoph Hellwig To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-raid@vger.kernel.org, linux-mmc@vger.kernel.org, linux-nvdimm@ml01.01.org, linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com, megaraidlinux.pdl@broadcom.com, sparmaintainer@unisys.com, devel@driverdev.osuosl.org, target-devel@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, dm-devel@redhat.com, Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Jens Axboe , Greg Kroah-Hartman , Dan Williams , Ross Zwisler , Matthew Wilcox , Sumit Semwal , Stephen Bates Subject: Re: [PATCH v2 01/21] scatterlist: Introduce sg_map helper functions Message-ID: <20170426074416.GA7936@lst.de> References: <1493144468-22493-1-git-send-email-logang@deltatee.com> <1493144468-22493-2-git-send-email-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1493144468-22493-2-git-send-email-logang@deltatee.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 25, 2017 at 12:20:48PM -0600, Logan Gunthorpe wrote: > This patch introduces functions which kmap the pages inside an sgl. > These functions replace a common pattern of kmap(sg_page(sg)) that is > used in more than 50 places within the kernel. > > The motivation for this work is to eventually safely support sgls that > contain io memory. In order for that to work, any access to the contents > of an iomem SGL will need to be done with iomemcpy or hit some warning. > (The exact details of how this will work have yet to be worked out.) I think we'll at least need a draft of those to make sense of these patches. Otherwise they just look very clumsy. > + * Use this function to map a page in the scatterlist at the specified > + * offset. sg->offset is already added for you. Note: the semantics of > + * this function are that it may fail. Thus, its output should be checked > + * with IS_ERR and PTR_ERR. Otherwise, a pointer to the specified offset > + * in the mapped page is returned. > + * > + * Flags can be any of: > + * * SG_KMAP - Use kmap to create the mapping > + * * SG_KMAP_ATOMIC - Use kmap_atomic to map the page atommically. > + * Thus, the rules of that function apply: the > + * cpu may not sleep until it is unmaped. > + * * SG_MAP_MUST_NOT_FAIL - Indicate that sg_map must not fail. > + * If it does, it will issue a BUG_ON instead. > + * This is intended for legacy code only, it > + * is not to be used in new code. I'm sorry but this API is just a trainwreck. Right now we have the nice little kmap_atomic API, which never fails and has a very nice calling convention where we just pass back the return address, but does not support sleeping inside the critical section. And kmap, whіch may fail and requires the original page to be passed back. Anything that mixes these two concepts up is simply a non-starter.