From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13154C47082 for ; Mon, 31 May 2021 08:19:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9829C611EE for ; Mon, 31 May 2021 08:19:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9829C611EE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 309CE6B0070; Mon, 31 May 2021 04:19:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B9926B0071; Mon, 31 May 2021 04:19:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E4D38D0001; Mon, 31 May 2021 04:19:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id C92346B0070 for ; Mon, 31 May 2021 04:19:25 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 64ED08249980 for ; Mon, 31 May 2021 08:19:25 +0000 (UTC) X-FDA: 78200826690.23.F2208CF Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf19.hostedemail.com (Postfix) with ESMTP id 576E59001E5E for ; Mon, 31 May 2021 08:19:11 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 406092191B; Mon, 31 May 2021 08:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622449163; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JlzazUtEmtoadridASgILyqQxnhngXX4KEnMbi5q6xg=; b=OuD+AINjEeahKJt5AYuPK7OpdtmSIE7UGcXtvNKnEGcocYDC0JGZtvtWmXny1+b+lW05iE 0ZYOSgq66Xw9Lpfu8UNKgo9rkL1197sb2VMPEFcm6aCDLgo4LuigFFuFnjqNvCgXddexyu IRHibs0bznMqcrhJDDGNyFyy+mHYsws= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622449163; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JlzazUtEmtoadridASgILyqQxnhngXX4KEnMbi5q6xg=; b=ltknWAiucss/xC/IeLI9znxs3U+QnNVcxPwsnwXnDBl9cULDuoI8kMLZXAt0qHGfljyRaI Sm5fThRGU2stNvCw== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 08D65118DD; Mon, 31 May 2021 08:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1622449163; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JlzazUtEmtoadridASgILyqQxnhngXX4KEnMbi5q6xg=; b=OuD+AINjEeahKJt5AYuPK7OpdtmSIE7UGcXtvNKnEGcocYDC0JGZtvtWmXny1+b+lW05iE 0ZYOSgq66Xw9Lpfu8UNKgo9rkL1197sb2VMPEFcm6aCDLgo4LuigFFuFnjqNvCgXddexyu IRHibs0bznMqcrhJDDGNyFyy+mHYsws= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1622449163; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JlzazUtEmtoadridASgILyqQxnhngXX4KEnMbi5q6xg=; b=ltknWAiucss/xC/IeLI9znxs3U+QnNVcxPwsnwXnDBl9cULDuoI8kMLZXAt0qHGfljyRaI Sm5fThRGU2stNvCw== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id ADQsAQuctGCCMQAALh3uQQ (envelope-from ); Mon, 31 May 2021 08:19:23 +0000 Subject: Re: [PATCH v7] mm: slub: move sysfs slab alloc/free interfaces to debugfs To: Faiyaz Mohammed , 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> From: Vlastimil Babka Message-ID: <043cfec6-7881-46e8-ec9c-3b4d6611ac2c@suse.cz> Date: Mon, 31 May 2021 10:19:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [0.00 / 100.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[11]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_CC(0.00)[linux.com,kernel.org,google.com,lge.com,linux-foundation.org,kvack.org,vger.kernel.org,gmail.com,codeaurora.org] Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=OuD+AINj; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ltknWAiu; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=OuD+AINj; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ltknWAiu; dmarc=none; spf=pass (imf19.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 576E59001E5E X-Stat-Signature: irt7c4ouk1xyswsz631rk94obdn81sok X-HE-Tag: 1622449151-929792 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. >>> 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 >>> >> >