Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2463503pxj; Mon, 31 May 2021 02:52:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnYif7b2EQ9zLo40XJTMQuV3s5vUeiDzyaR6wF1MS0GvYm+LkqZ1XMPZqb1Bs4pojfXKSx X-Received: by 2002:aa7:d7d5:: with SMTP id e21mr24774640eds.78.1622454768196; Mon, 31 May 2021 02:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622454768; cv=none; d=google.com; s=arc-20160816; b=wK+4iQI5xTR0cPi1utd7KVKQS/mz5jDzDlQJvu2pT049bAquSwtfHFArw0YT0SNDgQ gvQCIb33mH41m+TeYqTAds+kOl/64vQcfZgscvt8EeKePARJwVtcWTv0QYx5f9pOa/60 LT5Vw+1HaQxGOr47I+jsI+QN+b4qdueRhDI5BvEqX6pwSh0AXd91nRMt9s2Q/fytukM7 h3CJNzRg+wz8GHXyaV7oc6RLIKxiK1A9cJ2IroiYPooaAiKn2XWNYKkGIziScBcEj16E mkXPtD+S/njYWiNBhjtIH2DKkxeL5dDkIpleZVFwCu6eYlydxmnxhnX2HgguQUnEbhjA 8DnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=q7Wz7E8q1Z+/6dUG1hU3N6iWpBVBOzCSwDl6PQVYNuY=; b=izM7zbz3eb2TxCdLxteNXJAigT5F2bOwADZ23wUpB9OG2ixBk9wwnowjt5PpO2dGM1 Xl6qC16y0ESd28Mk2rwV5vNPOO8SE14c69efh4ccMC13zicWa3Dg3gbGulxGZl82dIFi 13Ft8aTqZs0lRC+nEEeil5Ufl2e7PJMLNyE+HTdLjt/YPLU5WS1ODJZs3FcG5AHMGVCx 6IG34Sdv47uE3dfwMTVCBaQI0EIEKuIQM0uw66L2aQFIlkXIEWCySO0HfLzLnD7PAXBT DFzVBiWLGqorFDDxC9VGLrzN64QjMxmkbunb+GkK19h4Kq/VhRRb/eHLwM6ur4K8hHTH ZpRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=ixRkyP3O; 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 p3si11766601ejz.123.2021.05.31.02.52.24; Mon, 31 May 2021 02:52:48 -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=@mg.codeaurora.org header.s=smtp header.b=ixRkyP3O; 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 S231144AbhEaJwu (ORCPT + 99 others); Mon, 31 May 2021 05:52:50 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:52658 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230520AbhEaJwq (ORCPT ); Mon, 31 May 2021 05:52:46 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1622454667; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=q7Wz7E8q1Z+/6dUG1hU3N6iWpBVBOzCSwDl6PQVYNuY=; b=ixRkyP3OaAPFFZFjH1ZgfkFPzK5YMgb+cAEiYZx/Hl6LVLMDgFoDiL9iE+5x1asoDJRhaHkA Jb0/LXlCfJismts7WrIFEeFkEVMU2j9OBfYR8+BdcdxDZkGuXVXs1j27sK/ROlKOVxate5l4 31igUWLZBh9RtHd03IOv9hr609A= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 60b4b177ea2aacd729c13f1b (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 31 May 2021 09:50:47 GMT Sender: faiyazm=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B7F38C433F1; Mon, 31 May 2021 09:50:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.0.105] (unknown [49.204.182.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: faiyazm) by smtp.codeaurora.org (Postfix) with ESMTPSA id 82705C433F1; Mon, 31 May 2021 09:50:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 82705C433F1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=faiyazm@codeaurora.org Subject: Re: [PATCH v7] mm: slub: move sysfs slab alloc/free interfaces to debugfs To: Vlastimil Babka , Greg KH Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, glittao@gmail.com, vinmenon@codeaurora.org References: <1621928285-751-1-git-send-email-faiyazm@codeaurora.org> <86d843f0-bbef-7c3b-6b6a-5d6b32434bee@suse.cz> <0b0e5e43-2ccf-a8a4-1e3b-ab2326c55321@suse.cz> <043cfec6-7881-46e8-ec9c-3b4d6611ac2c@suse.cz> From: Faiyaz Mohammed Message-ID: <2fc580b5-13a5-1a54-fe0b-9843ec685e64@codeaurora.org> Date: Mon, 31 May 2021 15:20:40 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <043cfec6-7881-46e8-ec9c-3b4d6611ac2c@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/31/2021 1:49 PM, Vlastimil Babka wrote: > On 5/31/21 9:11 AM, Faiyaz Mohammed wrote: >> >> >> On 5/26/2021 5:43 PM, Vlastimil Babka wrote: >>> On 5/26/21 1:48 PM, Greg KH wrote: >>>> On Wed, May 26, 2021 at 01:38:55PM +0200, Vlastimil Babka wrote: >>>>> >>>>> alias_list a single list and both slab_sysfs_init() and slab_debugfs_init() >>>>> flush it. So only the init call that happens to be called first, does actually >>>>> find an unflushed list. I think you >>>>> need to use a separate list for debugfs (simpler) or a shared list with both >>>>> sysfs and debugfs processing (probably more complicated). >>>>> >>>>> And finally a question, perhaps also for Greg. With sysfs, we hand out the >>>>> lifecycle of struct kmem_cache to sysfs, to ensure we are not reading sysfs >>>>> files of a cache that has been removed. >>>>> >>>>> But with debugfs, what are the guarantees that things won't blow up when a >>>>> debugfs file is being read while somebody calls kmem_cache_destroy() on the cache? >>>> >>>> It's much harder, but usually the default debugfs_file_create() will >>>> handle this for you. See the debugfs_file_create_unsafe() for the >>>> "other" variant where you know you can tear things down "safely". >>> >>> Right, so IIUC debugfs will guarantee that while somebody reads the files, the >>> debugfs cleanup will block, as debugfs_file_get() comment explains. >>> >>> In that case I think we have the cleanup order wrong in this patch: >>> >>> shutdown_cache() should first do debugfs_slab_release() (which would block) and >>> only then proceed with slab_kmem_cache_release() which destroys the fundamental >>> structures such as kmem_cache_node, which are also accessed by the debugfs file >>> handlers. >>> >> If user is trying to read the data during shutdown_cache(), then I think >> it's possible user will get empty data, to avoid that we can call > > Empty data is fine, when the cache is going away anyway. > >> debugfs_slab_release() first and then do other stuff in shutdown_cache(). > > Everything above list_del(&s->list) should be OK, it's equivalent to normal > cache operations which the debugfs files must cope with anyway. > list_del(&s->list) is OK as the debugfs handlers don't go through the list. It's > slab_kmem_cache_release() that matters. > okay, I will move debugfs_slab_release() before the slab_kmem_cache_release() in next patch version. >>>> That being said, yes there are still issues in this area, be careful >>>> about what tools you expect to be constantly hitting debugfs files. >>> >>> FWIW, the files are accessible only to root. >>> >>>> thanks, >>>> >>>> greg k-h >>>> >>> >> >