Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp373765rwb; Thu, 11 Aug 2022 03:11:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ru20KkBUZ4AzcWT9tBgWwcAD7rEthB39Bc7iocpUy9cwXiS7p3B22Tq7Oxp0c4p2ffB7A X-Received: by 2002:a05:6402:530f:b0:43e:43d7:91ca with SMTP id eo15-20020a056402530f00b0043e43d791camr30586721edb.176.1660212686377; Thu, 11 Aug 2022 03:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660212686; cv=none; d=google.com; s=arc-20160816; b=Jo6TFk2TaYFLlJoP7Q+hK4XFs0Sm3LGI1DplcP5XxLxyGbjrbYWYJEpPHsQto5k2GM fnX0/5dk7pjgIQlW6CljHydT5x3OQZ9YGOXdgQMBj1OGo3DGobWOYmHkvXETaM0c2ylZ XszOGXMAGpHFB9V5Jdsqgf66bzWuXYJKtWjMuRnxu3jZy7PrUz5ucjb5he3fm18qlJ9k 4ak0o4+aFzzGW1zSa/IxYsw+Eh5Vt4bEu+42mrHqQLpunCD3K+yWfZKBCqcEjGP9W1oc mAyJXWFuSyeaT8j/Mrk15LRT9GjWHT76gYkzk+sqXJf264+Iwex+nR6HPFAbvnBOj6Lb ZSwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:content-language:subject:from:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=mCxIbVIOyyg/Zymr2tIkgto6cQ3worjVRRoTjkKlzPg=; b=L2rADPRv4fvCYrYX33y9PSb6rGb0rirOeeFAjn3Y3OK7zgAODNoxJXEhHfu0oovxmO YAxyWoIL8zGKaZPF+9NXTU/wsT/XbNkATAFaYe+ZnOV6w1KRXLU//a75sMbY1tJzC5uN y6yv/n9EWKvQMXCV33T7ZL3+1k/Y2EK07fMhnNrCnnE/Dicg767/MLLSgshBcIr3zK2+ VFGJEF3G/qFAZXeVEHCfWx0wCPv3Bw58So34DiqRvvhMwUiev0Vevs8okeC4+rv4QHT8 4LW06i/cPDmB1aJ40JbIUFID0AjXprbArbItxz6vmsrUHbYREskyW5JwbXgiJtd/Oy1P DsSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZNWqhyyQ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020a056402121900b0043de10b9d72si12695578edw.315.2022.08.11.03.11.00; Thu, 11 Aug 2022 03:11:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ZNWqhyyQ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234884AbiHKKHp (ORCPT + 99 others); Thu, 11 Aug 2022 06:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbiHKKHn (ORCPT ); Thu, 11 Aug 2022 06:07:43 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEA488E9A2 for ; Thu, 11 Aug 2022 03:07:41 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 860A5204E2; Thu, 11 Aug 2022 10:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1660212460; 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=mCxIbVIOyyg/Zymr2tIkgto6cQ3worjVRRoTjkKlzPg=; b=ZNWqhyyQ3JjW94SuNhBv3arPNAEn48sHsyC4bc6kInzWlhdT4DnTntYnORQ76CzbaFaFQq 9PgK8V/Hmy6xyOcF47pv5wQ4zAAMs5IpZa0uLYhY2BORYGmAKo0lkN4MMx3tEFecJdFeBj U4EEZa8P/G3uUaj/jZEHdu08EVmxpMw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1660212460; 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=mCxIbVIOyyg/Zymr2tIkgto6cQ3worjVRRoTjkKlzPg=; b=ijjg7SCgXM0l9/3G4pStwk0NYslTQW2C6OFiyUvr8jTO8AmBsyNUWx4EE0crdLr94EkXSV ObhhLYzHwhxjN0Aw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4C97513A9B; Thu, 11 Aug 2022 10:07:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MhDqEezU9GJiAgAAMHmgww (envelope-from ); Thu, 11 Aug 2022 10:07:40 +0000 Message-ID: <6b41bb2c-6305-2bf4-1949-84ba08fdbd72@suse.cz> Date: Thu, 11 Aug 2022 12:07:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 From: vbabka@suse.cz Subject: Re: [PATCH v2] Introduce sysfs interface to disable kfence for selected slabs. Content-Language: en-US To: Marco Elver Cc: Imran Khan , glider@google.com, dvyukov@google.com, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org References: <20220811085938.2506536-1-imran.f.khan@oracle.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/22 11:52, Marco Elver wrote: > On Thu, 11 Aug 2022 at 11:31, wrote: >> >> On 8/11/22 10:59, Imran Khan wrote: >> > By default kfence allocation can happen for any slab object, whose size >> > is up to PAGE_SIZE, as long as that allocation is the first allocation >> > after expiration of kfence sample interval. But in certain debugging >> > scenarios we may be interested in debugging corruptions involving >> > some specific slub objects like dentry or ext4_* etc. In such cases >> > limiting kfence for allocations involving only specific slub objects >> > will increase the probablity of catching the issue since kfence pool >> > will not be consumed by other slab objects. >> >> So you want to enable specific caches for kfence. >> >> > This patch introduces a sysfs interface '/sys/kernel/slab//skip_kfence' >> > to disable kfence for specific slabs. Having the interface work in this >> > way does not impact current/default behavior of kfence and allows us to >> > use kfence for specific slabs (when needed) as well. The decision to >> > skip/use kfence is taken depending on whether kmem_cache.flags has >> > (newly introduced) SLAB_SKIP_KFENCE flag set or not. >> >> But this seems everything is still enabled and you can selectively disable. >> Isn't that rather impractical? > > A script just iterates through all the caches that they don't want, > and sets skip_kfence? It doesn't look more complicated. Well, yeah, it's possible. >> How about making this cache flag rather denote that KFENCE is enabled (not >> skipped), set it by default only for for caches with size <= 1024, then you > > Where does 1024 come from? PAGE_SIZE? You're right, the existing check in __kfence_alloc() uses PAGE_SIZE, not 1024, which probably came from lack of coffee :) > The problem with that opt-in vs. opt-out is that it becomes more > complex to maintain opt-in (as the first RFC of this did). With the I see. There was a kfence_global_alloc_enabled and slub_kfence[=slabs] ... that probably wouldn't be necessary even in an opt-in scenario as I described. > new flag SLAB_SKIP_KFENCE, it also can serve a dual purpose, where > someone might want to explicitly opt out by default and pass it to > kmem_cache_create() (for whatever reason; not that we'd encourage > that). Right, not be able to do that would be a downside (although it should be possible even with opt-in to add an opt-out cache flag that would just make sure the opt-in flag is not set even if eligible by global defaults). > I feel that the real use cases for selectively enabling caches for > KFENCE are very narrow, and a design that introduces lots of > complexity elsewhere, just to support this feature cannot be justified > (which is why I suggested the simpler design here back in > https://lore.kernel.org/lkml/CANpmjNNmD9z7oRqSaP72m90kWL7jYH+cxNAZEGpJP8oLrDV-vw@mail.gmail.com/ > ) I don't mind strongly either way, just a suggestion to consider.