Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp290130pxa; Thu, 27 Aug 2020 02:20:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGeB6b8iDRTB0gyYzS9PgKiW21laeEOeqiJd7dC1b5BhRQsihDhTfoc2LL6vivCgFseK/F X-Received: by 2002:a50:cddd:: with SMTP id h29mr5732462edj.96.1598520012668; Thu, 27 Aug 2020 02:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598520012; cv=none; d=google.com; s=arc-20160816; b=K51qdJ1ja006juzjn64YgNf20kDXijyii575uRdtju7YkZYpQD2O19w/8pPkBBre6R JCOhng/zNorx8PKsschTAl39RmDEq8DfKMO6V31c7YoeaiT9eR1JAfFzGCrRKG0782hi 1xS4UsO4HJ0NEPbAq3axgKhginzlSwimdhAtAFZyaAdjjY7t365YQ6eijjXdJEptvZhX Ti6CN5VaE7OtPAXIvwTtsUPYMZmOnDMAxo4TwLW8CAtcEHGtGvmb6sa9h1OmK+0VT4N2 9CX7iMO2dzQQm7fgn36OjJ51CIhKMVPG0NuzfHdUghEQg3pLZcF9hFBKjITCLbOve/SJ aq/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JKvsMjFH7HsHO6wdMbfQRaeDXmggYNE35Nrp/z9nbkE=; b=nIqn1AS69E2IlBtTsuFbIk2OwFu2ZWxEfcZ9YZLHNMH18xdHcnKcyy5pu1fekNtFHc 5qtNCYuNJRHURyFTUFd4JAHfMrUpF4L8X8prRUfAxq6YqaKeyB8hQF2Syn3ywysVYOcR 8dEesz3wkQyujZd07t7BMSHkPBMVeN79O8R4S6QgqMDFQAVtZoo8JrqsnIMZUyYXmDcd ZlM96Zo6EKfb3/6RU+4KkSNrq8cjOhj1v4xuDZf0bE++FRUOfqsXqaUIJAxLcWaEMug2 yNqmjx1FkEP5xHHO49NZN+63dIH4yFdtPbFjVoR7JapJLYG4T9zg7BXSwGpFnnIz9EBO H7CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=esepNnSV; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si1417833edj.505.2020.08.27.02.19.50; Thu, 27 Aug 2020 02:20:12 -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; dkim=pass header.i=@kernel.org header.s=default header.b=esepNnSV; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbgH0JSu (ORCPT + 99 others); Thu, 27 Aug 2020 05:18:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:33036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727897AbgH0JSq (ORCPT ); Thu, 27 Aug 2020 05:18:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 045052080C; Thu, 27 Aug 2020 09:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598519925; bh=eyGOZg/y/QcXFOJgZoOtuvDPU8rg6VzNRmKctKnURZ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=esepNnSVmYNkD0epnb+1wYHjyodtG/x2Cmq2wrlli5PQv1aBJjWgCRTPt/ft3mz+I s/wnvmq66qRfKMb4MQ4H9Na9SVr8U5ojM6LGZImkQMCmUvbnbLe31AMAI8dIVfLXiS wQZFDGO9yA5Zd9spv8Tlcm2nIEUNchgvtUYp/LyU= Date: Thu, 27 Aug 2020 11:18:59 +0200 From: Greg Kroah-Hartman To: Christoph Hellwig Cc: 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: <20200827091859.GA393660@kroah.com> References: <20200826062446.31860-1-hch@lst.de> <20200826062446.31860-2-hch@lst.de> <20200826081905.GB1796103@kroah.com> <20200827085353.GA12111@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200827085353.GA12111@lst.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 10:53:53AM +0200, Christoph Hellwig wrote: > 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. Ok, great! xarrays weren't around when this code was written (back in the 2.5 days). > > > + 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. It does? Where does that happen? I see a bunch of kobject_init() calls, but nothing that registers it in sysfs that I can see. Note, this is not the kobject that shows up in /sys/dev/char/ as a symlink, that comes from the driver core logic and is independent of the cdev code. The kobject does handle the structure lifetime rules, but that should be able to be replaced with a simple kref instead. > 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). Fair enough, I will be willing to tackle that once this gets merged, so this is fine as-is. thanks, greg k-h