Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E050C433F5 for ; Tue, 8 Feb 2022 15:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230234AbiBHPVy (ORCPT ); Tue, 8 Feb 2022 10:21:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379858AbiBHPVx (ORCPT ); Tue, 8 Feb 2022 10:21:53 -0500 X-Greylist: delayed 98 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 08 Feb 2022 07:21:52 PST Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 6A6D1C061579 for ; Tue, 8 Feb 2022 07:21:52 -0800 (PST) Received: (qmail 529266 invoked by uid 1000); 8 Feb 2022 10:21:51 -0500 Date: Tue, 8 Feb 2022 10:21:51 -0500 From: Alan Stern To: Ingo Rohloff Cc: Greg KH , balbi@kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v2 1/1] usb: gadget: f_fs: Support zerocopy transfers via mmap. Message-ID: References: <20220202172056.44722-1-ingo.rohloff@lauterbach.com> <20220202172056.44722-2-ingo.rohloff@lauterbach.com> <20220208124817.3bd884ba@ingpc2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220208124817.3bd884ba@ingpc2> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Tue, Feb 08, 2022 at 12:48:17PM +0100, Ingo Rohloff wrote: > > > + atomic64_sub(amount, &ffs->mmap_mem_usage); > > > > Why not use a real lock instead of trying to do a fake one with this > > atomic variable? > > I don't think there is a good reason using the "atomic" stuff: > I think this code path anyway is not hit that often (only when you mmap or > munmap buffers), so this should not have any noticeable impact on performance. > > I just took the code from "drivers/usb/core/devio.c", > "usbfs_increase_memory_usage()". > I am still convinced it is correct. > > You are of course right: You can easily use a lock here and this makes the > intention of the code a lot clearer I guess. > > I will modify the patch accordingly. If you also feel like making a similar change to the code in devio.c, it would be welcome. Alan Stern