From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id 1CC824252C3 for ; Sat, 22 Apr 2023 00:34:24 +0200 (CEST) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1a66911f5faso23687345ad.0 for ; Fri, 21 Apr 2023 15:34:24 -0700 (PDT) Date: Sat, 22 Apr 2023 08:34:20 +1000 From: Dave Chinner To: Luis Chamberlain Message-ID: <20230421223420.GH3223426@dread.disaster.area> References: <20230421195807.2804512-1-mcgrof@kernel.org> <20230421195807.2804512-4-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: djwong@kernel.org, philipp.reisner@linbit.com, linux-mm@kvack.org, dm-devel@redhat.com, agk@redhat.com, drbd-dev@lists.linbit.com, Matthew Wilcox , hch@infradead.org, p.raghav@samsung.com, senozhatsky@chromium.org, snitzer@kernel.org, linux-block@vger.kernel.org, hare@suse.de, kbusch@kernel.org, axboe@kernel.dk, da.gomez@samsung.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, minchan@kernel.org, patches@lists.linux.dev, linux-fsdevel@vger.kernel.org, lars.ellenberg@linbit.com Subject: Re: [Drbd-dev] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Fri, Apr 21, 2023 at 03:02:30PM -0700, Luis Chamberlain wrote: > On Fri, Apr 21, 2023 at 09:14:00PM +0100, Matthew Wilcox wrote: > > On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: > > > Just use the PAGE_SECTORS generic define. This produces no functional > > > changes. While at it use left shift to simplify this even further. > > > > How is FOO << 2 simpler than FOO * 4? > > > > > - return bioset_init(&iomap_ioend_bioset, 4 * (PAGE_SIZE / SECTOR_SIZE), > > > + return bioset_init(&iomap_ioend_bioset, PAGE_SECTORS << 2, > > We could just do: > > > - return bioset_init(&iomap_ioend_bioset, 4 * (PAGE_SIZE / SECTOR_SIZE), > + return bioset_init(&iomap_ioend_bioset, 4 * PAGE_SECTORS, Yes, please. > The shift just seemed optimal if we're just going to change it. Nope, it's just premature optimisation at the expense of maintainability. The compiler will optimise the multiplication into shifts if that is the fastest way to do it for the given architecture the code is being compiled to. -Dave. -- Dave Chinner david@fromorbit.com