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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89631C27C53 for ; Wed, 19 Jun 2024 17:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1CA38D0088; Wed, 19 Jun 2024 13:48:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCC548D0084; Wed, 19 Jun 2024 13:48:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABA3C8D0088; Wed, 19 Jun 2024 13:48:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8DEB98D0084 for ; Wed, 19 Jun 2024 13:48:02 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0F674A1454 for ; Wed, 19 Jun 2024 17:48:01 +0000 (UTC) X-FDA: 82248371604.24.8D9F660 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) by imf27.hostedemail.com (Postfix) with ESMTP id A4FAF4001C for ; Wed, 19 Jun 2024 17:47:59 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AXDSTMfk; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf27.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718819273; a=rsa-sha256; cv=none; b=mrB3NouHMNMjjT0ungxOyDjq3+1PxuQ8mIsiAcdED3yTQM9apH90V5LKodaOpqJY+oM6Ay PkxChBCW/FG8mP2LdkgJ9TNM3oKrq4vs/XwfizMwOvfhe2LIQUB30/1sAkabwqOy7C7W2Z N21ndfJYRPQnxXMu5TCAfzR696w1djI= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AXDSTMfk; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf27.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718819273; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=I36DV95vqg3WqUSWDkFF1xu/gEicJbY8yx8D+wSVUZc=; b=4P/kYDuoSLiPx4PeV5JhpHlEcezOqBl2g7wwdu/MU1cUgwFdyRbi9tlcL7TAFuNfeAX9xJ NqQRbbNmM8mUxDn6BjboqfdVSOkUN92PxtAyIouUQZWXH5/U0Cz/HxoI3fVVk9yTyHj23Q aJuxRuaOZXEcEU5fmke47SYcQmFLqUk= X-Envelope-To: mhocko@suse.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718819277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=I36DV95vqg3WqUSWDkFF1xu/gEicJbY8yx8D+wSVUZc=; b=AXDSTMfkK8VrfSMgByU0uszIDqYXPWzUNL7x80mmYOZFY2TVPKas1ocvhN7g8qXV8qpwiR WPoRoZJysjCsATvhAoEYNCJglBpDR0cCYsaZj+i7iAsAvH5l/evuh0x0ACe/KjLkni78rN WUpmDuKMt8vlWNQNxh2ZTCkAOpkhw1I= X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: torvalds@linux-foundation.org X-Envelope-To: kernel-team@meta.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: kyle@infradead.org Date: Wed, 19 Jun 2024 10:47:51 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Michal Hocko Cc: Andrew Morton , Linus Torvalds , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kyle McMartin Subject: Re: [PATCH] mm: ratelimit oversized kvmalloc warnings instead of once Message-ID: <20240619174751.7r2s7iojxbaxpqlw@linux.dev> References: <20240618213421.282381-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A4FAF4001C X-Stat-Signature: ob6h3fa55yfnpk8jqjakwyzbacefdfap X-Rspam-User: X-HE-Tag: 1718819279-59505 X-HE-Meta: U2FsdGVkX18OC8WdRyBHmI42KRQxps1DHDwSlX6CuWJl52ME+3h81MpuoA05sUjqMgXPn8Fjug/sij4DLWq2bSJoKKcKhEpkZ0w6/dsk3FVKJiX7Czk0pkepKpSgURWKoZntf44fGxGl7y4niDsDNLd/mxVwcHhV5tgYukqX0bTdUtyhyn7u+HXVlmOyvyvIkNOCgl90+ZwEfkIoNe/DijeGXuu8I6y7RUQiiODeXgp2hQ98O+D8ecNKBRrjPdkkUgI/s0Qd+kk2VOm44jkRUyqXZv3oA/4WSszSRP3nFIRXdYdHAPaKJanDFXpXXWvSpKObNSjavl3GQYae27XVdiZ/zqtPaMCUdndjBJiKwo7eW71i1yawuJLN6vViOytZJOE2khxD0pw/SBDLo7xqwMO0aNBx5DwCKQjoOjNZlr6HjUVDRCC4nB+zJtPKJs1YdyG1Yjcpkej/L71Ld4z4mLBqs6z49vtuYVxg6OAZuBJylLShV0hHD2QwUWXXOlgeM+JV5uThpqux5b7b0Nl1XXtiQODP2KcSAlU55m4bmnVpy5dfLUK8Gma1JDs/N3h/oZ9B9AoEqHdJsqm1f/9uo5FpAqZ3pAaJ1LEtXNRydEe2F/kqVVRd/oiuRcJ025Cl/TrXhg2WgmbJOu/Xt6GkrwtMoLBtF0j8sQUufEyGie3K8U+53YtO3EK8At3GApJb7GsyMsbpwXzhFQodQ0Q0ZTOwHYeft5k0BqWkRp7Cjph0GUGzIugE96zSYYyiZfvcP6Awsnbz1iLFxcv1amotNm6TrDuIuX3QJyMQr36j0rI945eZhX8ql9eOYluSba0f6In0bp/1kcDDHSnfoLZvhaTp6eE1jk+ZIwJtqQRN7/BQfdu5jrrtaduokVbD6mhZooeWpyLNcarpgt/9yO8k8VkhLqqNvS8bdkKWRugIhPp1jAgIC1Ne1QlEGMsICQj2W8ADFBkj1d5S96D18EC g7U7pM3Q 1Y5IIGndODED3rqjPaDU3PLGuTDhqZcUqSBvF51gXUNIOVnM2028mZI3K6RQzOlD4mrHCfOBec21Tw3mtK/GwEjuLXZeb9oI6oFHRgZp8WoN5qH7I+tuNpa+Mnzdes+glgd9PDk8vS21VA8Fq9fYYvdq2Z+mbv9WFl4Vat0INWoaW1r8k4RLGha/aag== 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: List-Subscribe: List-Unsubscribe: On Wed, Jun 19, 2024 at 10:48:07AM +0200, Michal Hocko wrote: > On Wed 19-06-24 10:30:46, Michal Hocko wrote: > > On Wed 19-06-24 01:03:16, Shakeel Butt wrote: > > > On Wed, Jun 19, 2024 at 09:19:41AM GMT, Michal Hocko wrote: > > > > On Tue 18-06-24 14:34:21, Shakeel Butt wrote: > > > > > At the moment oversize kvmalloc warnings are triggered once using > > > > > WARN_ON_ONCE() macro. One issue with this approach is that it only > > > > > detects the first abuser and then ignores the remaining abusers which > > > > > complicates detecting all such abusers in a timely manner. The situation > > > > > becomes worse when the repro has low probability and requires production > > > > > traffic and thus require large set of machines to find such abusers. In > > > > > Mera production, this warn once is slowing down the detection of these > > > > > abusers. Simply replace WARN_ON_ONCE with WARN_RATELIMIT. > > > > > > > > Long time ago, I've had a patch to do the once_per_callsite WARN. I > > > > cannot find reference at the moment but it used stack depot to note > > > > stacks that have already triggered. Back then there was no reponse on > > > > the ML. Should I try to dig deep and recover it from my archives? I > > > > think this is exactly kind of usecase where it would fit. > > > > > > > > > > Do you mean something like warn once per unique call stack? > > > > Exactly! > > > > > If yes then > > > I think that is better than the simple ratelimiting version as > > > ratelimiting one may still miss some abusers and also may keep warning > > > about the same abuser. Please do share your patch. > > > > https://lore.kernel.org/all/20170103134424.28123-1-mhocko@kernel.org/ > > Btw. the code has changed a lot since 2017 when this was posted so it > will likely need a lot of massaging to rebase. Also I am not entirely > sure it is ok to change WARN_ONCE semantic like that anymore. Maybe we > need an explicit variant that does this per-call-site warnings. It is a > notable difference between library functions which can be called from > different callpaths and those that are used from a single place. I do > not have much time to dig deeper into this but if you want to take over > then go ahead. I still think this is a useful WARN_ONCE or in general > do_something_once semantic. I think a separate variant like WARN_UNIQUE() would be better. I will look into this. Linus, please let me know if you have any concerns on the approach Michal is suggesting i.e. a variant for warn once for unique call stack. Shakeel