Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp278069pxa; Thu, 27 Aug 2020 01:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP6MfQWV62utHIJ9dPUYTVpAOMKSQw5gagNsjqQtQro8R9WRyXcFhG2MbnnVJv1scV0U8G X-Received: by 2002:a50:9fe6:: with SMTP id c93mr18178440edf.286.1598518506985; Thu, 27 Aug 2020 01:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598518506; cv=none; d=google.com; s=arc-20160816; b=Z3xRXZMglZZnsiAmSWmNJecPcBcBM6202+tAIqTCedw/9a+GwFENUJW6iIaz4Y/ooJ HkVOmfJaLCDVYRiJ9M+Ntz402UD7fDByqORoB4II5jjD03RxiSM9YFwuSjqf6t4C6ADt bCv5DuuSH8NNvfYWrFNOlwZLhQLGtPI3wAUFRdHFGdeApAym274zQlsRtHt08W3oaVEE 2NywfMhuERZSi80zyRz+cP0TcM9W3eEn2y2tuis2rabklqB8wT97mQppHrpCwe+tjL2z VPZsnCUQSEm4mfLjJAJqNF5kGTMPCmiS/G/kkIb/O9Oo561CQhLMfiEhP0JnbQ9+Papw n7Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=SHS9pOpu0/yslwmDAIbvmngknejWasZhY7XREYXmUBk=; b=AiUMx0Q3C4zb5Q4XnrivLlCNOFSMm+wGEblLxHBqkc3OsO7dpipQucdI+OfCgmf3fd o+kS7QHdhn+bIhLf5HkwQIQjhdkdFU+KVgCoalpcAaI6fRZYL9722O94lNuskvEOgYNn GEsUbJ693H2f5HLtvn91uXtj2WjN1iOn9oZUgYqox/FcHAfDq24Cg7g25se9s8dmabdK EyPfqoMEquRIe/NQ7t2iTVYwmS2qrvvTmDNfudeq6BqYi+pwW12ms6l8jtdDQ140PuOT sGAvmO0ZHqlITRBcNAj8rV2T31OQnh8fZUgK1KiFFHTWuqfx6EkY6vH5llkY3YcNh1n5 VdLg== 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 v16si1141219ejk.147.2020.08.27.01.54.44; Thu, 27 Aug 2020 01:55:06 -0700 (PDT) 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 S1728147AbgH0IyG (ORCPT + 99 others); Thu, 27 Aug 2020 04:54:06 -0400 Received: from verein.lst.de ([213.95.11.211]:37293 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728001AbgH0Ix6 (ORCPT ); Thu, 27 Aug 2020 04:53:58 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id C68FE68B02; Thu, 27 Aug 2020 10:53:53 +0200 (CEST) Date: Thu, 27 Aug 2020 10:53:53 +0200 From: Christoph Hellwig To: Greg Kroah-Hartman Cc: Christoph Hellwig , Jens Axboe , "Rafael J. Wysocki" , Denis Efremov , "David S. Miller" , Song Liu , Al Viro , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, linux-raid@vger.kernel.org, linux-scsi@vger.kernel.org, linux-m68k@lists.linux-m68k.org Subject: Re: [PATCH 01/19] char_dev: replace cdev_map with an xarray Message-ID: <20200827085353.GA12111@lst.de> References: <20200826062446.31860-1-hch@lst.de> <20200826062446.31860-2-hch@lst.de> <20200826081905.GB1796103@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200826081905.GB1796103@kroah.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 10:19:05AM +0200, Greg Kroah-Hartman wrote: > On Wed, Aug 26, 2020 at 08:24:28AM +0200, Christoph Hellwig wrote: > > None of the complicated overlapping regions bits of the kobj_map are > > required for the character device lookup, so just a trivial xarray > > instead. > > > > Signed-off-by: Christoph Hellwig > > Really? This is ok to use and just as fast? If so, wonderful, it would > be great to clean up kobj_map users. Xarrays provide pretty efficient as long as we have a unsigned long or smaller index (check, dev_t is small) and the indices are reasonable clustered (check, minors for the same major). Memory usage will go down vs the probes, and lookup speed up. > > + mutex_lock(&chrdevs_lock); > > + for (i = 0; i < count; i++) { > > + error = xa_insert(&cdev_map, dev + i, p, GFP_KERNEL); > > + if (error) > > + goto out_unwind; > > + } > > + mutex_unlock(&chrdevs_lock); > > > > kobject_get(p->kobj.parent); > > Can't you drop this kobject_get() too? I'll have to drop it or add back the put on the delete side. And I think the latter is safer for now, because.. > > And also the "struct kobj" in struct cdev can be gone as well, as the > kobj_map was the only "real" user of this structure. I know some > drivers liked to touch that field as well, but it never actually did > anything for them, so it was pointless, but it will take some 'make > allmodconfig' builds to flush them out. I looked at it, but it does get registered and shows up in sysfs. I don't really dare to touch this for now, as it can have huge implications. Better done in a separate series (if we can actually do it at all).