Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp143108rwl; Wed, 9 Aug 2023 12:13:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiKVPQrXCOb1oYDimmTjcYpYT0rLloFQHDov3oHZ3kixPWKGTXUGsFn9sPK3VkCG7Ui9PG X-Received: by 2002:a17:906:1da1:b0:98d:f062:8503 with SMTP id u1-20020a1709061da100b0098df0628503mr1764ejh.77.1691608438278; Wed, 09 Aug 2023 12:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691608438; cv=none; d=google.com; s=arc-20160816; b=TGJFCzCIYLrZmaTrk0mZtLSNOrYHLdwOe9u8q2AhP7Eh017FLFn5CqUbCjcO1IO12t OVNIL51MrkI+YrL5so++Sg1deaBOefPWj4Tcl/s+BSX/i792LM7trUH9WoYTx1q8FTvH nv9RIv50gOa1Abj6R9mswSlpw+0uJxP7K35gyUK5P2XBHWRYFoTowrzoxM1e7MesRtfL ygDs8c16qiudrYxUPt1Rnnwc9c+B/2jPfwKF3dnzMBYKMZgKXT4nzPwumJt/tYmis9+3 FQiHAahCsG3HmGCY61jQaZE7Pkj2WzOWMTCCt7w/cPeJ30usPdVHpvx8FaEEq389O0Uh jk0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=d/gq723QsA/6CknCjB/Fdzmk8CYhQn0zlWCC+cFAbBw=; fh=7HRQlwLA+eAntB3E87f7KnqJZAZGzUw+Og8VrPTpE1Y=; b=s93pRDJ6//nhQFoA25p+EV/n2kbjhhMHsWf0TcMh/BZcJ4UXhNt08w9jsoTolnA/JI EmQiy3uxIUzBtElUQsT94FpCNlKYKMoS1E7ZBzFGCgL6v7UNsrVep/qDhqU0b5zKhN6+ +tvotl9vIxvOv4XmcTNl3QEN2TgFSxdwwfuRA+dO2i9RZrGAot0oiOBEAugJZ7GhcbkI ZOKc1KJcDLFjYlxq4wLk0Hg7TSn5cyr39bJHdGwn2VhBL9J9mffQIcb3nxy08vd+djGH QOoAbcQzJmvc256zD3GWOVKlp9PyttVg2twSOjiZ8sk6dH5JojDd1gMVkyRlIsuqo05z g2GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=WPdfms4B; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V7Mq+Gk1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pv17-20020a170907209100b0099bcf1c07cbsi3461753ejb.883.2023.08.09.12.13.33; Wed, 09 Aug 2023 12:13:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=WPdfms4B; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V7Mq+Gk1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbjHISIe (ORCPT + 99 others); Wed, 9 Aug 2023 14:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjHISId (ORCPT ); Wed, 9 Aug 2023 14:08:33 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62F4510F5; Wed, 9 Aug 2023 11:08:33 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2599F1F74B; Wed, 9 Aug 2023 18:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691604512; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=d/gq723QsA/6CknCjB/Fdzmk8CYhQn0zlWCC+cFAbBw=; b=WPdfms4BLORKMfcHSyWfESgFCMclUG4v3nLk9UFXGlmbeD52x2nr1nscxRSznzz/2Zdd/I Az8EXbi9ka3T4lA+vu9igWvJyNRAETjZ+rp9GHYA5AhbRxSskgOwJ+JvwJ81ohfkrRS2+7 alHr2UMv4U/LDsqvXplzShOvYZ6xiw4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691604512; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=d/gq723QsA/6CknCjB/Fdzmk8CYhQn0zlWCC+cFAbBw=; b=V7Mq+Gk1HCvqsIz/oD2NXNXV/cXmnvjKAscAFXE7mF6AAhSKuQ//xma2zYb2RBEwuoKAct fI01ItuzYPJEWQDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E4DBE13251; Wed, 9 Aug 2023 18:08:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XNfuNh/W02QxEQAAMHmgww (envelope-from ); Wed, 09 Aug 2023 18:08:31 +0000 Date: Wed, 09 Aug 2023 20:08:30 +0200 Message-ID: <87o7jgccm9.wl-tiwai@suse.de> From: Takashi Iwai To: Linus Torvalds Cc: Takashi Iwai , Christoph Hellwig , linux-kernel@vger.kernel.org, Andy Shevchenko , Mark Brown , netdev@vger.kernel.org Subject: Re: [PATCH RFC] Introduce uniptr_t as a generic "universal" pointer In-Reply-To: References: <87edkce118.wl-tiwai@suse.de> <20230809143801.GA693@lst.de> <87wmy4ciap.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 09 Aug 2023 19:01:50 +0200, Linus Torvalds wrote: > > On Wed, 9 Aug 2023 at 09:05, Takashi Iwai wrote: > > > > OTOH, it simplifies the code well for us; as of now, we have two > > callbacks for copying PCM memory from/to the device, distinct for > > kernel and user pointers. It's basically either copy_from_user() or > > memcpy() of the given size depending on the caller. The sockptr_t or > > its variant would allow us to unify those to a single callback. > > I didn't see the follow-up patches that use this, but... > > > (And yeah, iov_iter is there, but it's definitely overkill for the > > purpose.) > > You can actually use a "simplified form" of iov_iter, and it's not all that bad. > > If the actual copying operation is just a memcpy, you're all set: just > do copy_to/from_iter(), and it's a really nice interface, and you > don't have to carry "ptr+size" things around. > > And we now have a simple way to generate simple iov_iter's, so > *creating* the iter is trivial too: > > struct iov_iter iter; > int ret = import_ubuf(ITER_SRC/DEST, uptr, len, &iter); > > if (unlikely(ret < 0)) > return ret; > > and you're all done. You can now pass '&iter' around, and it has a > nice user pointer and a range in it, and copying that thing is easy. > > Perhaps somewhat strangely (*) we don't have the same for a simple > kernel buffer, but adding that wouldn't be hard. You either end up > using a 'kvec', or we could even add something like ITER_KBUF if it > really matters. > > Right now the kernel buffer init is a *bit* more involved than the > above ubuf case: > > struct iov_iter iter; > struct kvec kvec = { kptr, len}; > > iov_iter_kvec(&iter, ITER_SRC/DEST, &kvec, 1, len); > > and that's maybe a *bit* annoying, but we could maybe simplify this > with some helper macros even without ITER_KBUF. > > So yes, iov_iter does have some abstraction overhead, but it really > isn't that bad. And it *does* allow you to do a lot of things, and can > actually simplify the users quite a bit, exactly because it allows you > to just pass that single iter pointer around, and you automatically > have not just the user/kernel distinction, you have the buffer size, > and you have a lot of helper functions to use it. > > I really think that if you want a user-or-kernel buffer interface, you > should use these things. > > Please? At least look into it. All sounds convincing, I'll take a look tomorrow. Thanks! Takashi > > Linus > > (*) Well, not so strange - we've just never needed it. >