Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp291359pxb; Wed, 18 Nov 2020 04:49:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJznM7KkL8A/lFiWj5ZwKea/BKfVjQe+wHRvqUyC1CjzYTkAw70tuFBUCPxcse9PQEwWeRYz X-Received: by 2002:a17:907:2089:: with SMTP id pv9mr24290941ejb.34.1605703742670; Wed, 18 Nov 2020 04:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605703742; cv=none; d=google.com; s=arc-20160816; b=fMp1hYwC5xqT8KCAgABmgm0P4Dc24h4gA1KR3k9nckJAJPTAYfO8uDCnDpvSrFq74C aHbha5bNAe97SybVvDHhTP9UqOGVBDQnLgbJYkNez09Lg7bhhBhk63Ng8E0g5gFkkIbi H9aex0Gmj8j8qaMIlYn+tKxOvACNpyhaliZ2vfNnDywxWfWLkD0WyFAVxLxfW+3a999p QHrTuBRaJ1/nZE8XYHsA6y8lxQzCQXbBuWtXgAqcqP5OWtDDtQ4pPpQ52Ul2FMAPv0It iEG4XuKGnEUsutFCjGQn20FgPZwkqlN+SavNpKXpRrC5n4G2jhhN91Fkqy9aXsYUHqCI ymCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=gwAwDH89xjzQwj+Zf0NNrR3ceVa+pgEk3rO22bvzlXQ=; b=AxlwBqDvH8pr1VjY1xVd/ongcvkoncAMvQWZKlR5Idvap1S23GKRmvMjxqHn8GW9pc SE/Z880eHyAgY18bjhj5qUAWJvuDaXJJ6pGGo43HkkfE1UCnaNS9y6V7I04Pgi4/1sLL 2eLvqEUOeAyQMoywMEId+o4camdRu7sQeI27CosQDdsUbNK0N1UCN48fIP1FZBbWa20J 5dwwlssf8IncLe+UYfK7eubS8dQoALYUdZvhSIZ/HhKFm91Q7c4BboAV1vipVz/p9ZhN vpcwNyoCrrZIbobtSjkGCXrUvaTM2ds5HGThlCNxK9RC2aPJfwRaxgwB4e/kPHEsnBPL 4TtQ== ARC-Authentication-Results: i=1; mx.google.com; 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 bm4si6117178ejb.283.2020.11.18.04.48.39; Wed, 18 Nov 2020 04:49:02 -0800 (PST) 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; 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 S1726475AbgKRMqO (ORCPT + 99 others); Wed, 18 Nov 2020 07:46:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:55544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726020AbgKRMqO (ORCPT ); Wed, 18 Nov 2020 07:46:14 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 AF9A724180; Wed, 18 Nov 2020 12:46:10 +0000 (UTC) Date: Wed, 18 Nov 2020 07:46:09 -0500 From: Steven Rostedt To: Alexei Starovoitov Cc: LKML , Mathieu Desnoyers , Matt Mullins , paulmck , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann , Dmitry Vyukov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , netdev , bpf , Kees Cook , Peter Zijlstra , Josh Poimboeuf Subject: Re: [PATCH v2] tracepoint: Do not fail unregistering a probe due to memory allocation Message-ID: <20201118074609.20fdf9c4@gandalf.local.home> In-Reply-To: References: <20201117211836.54acaef2@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Nov 2020 20:54:24 -0800 Alexei Starovoitov wrote: > > extern int > > @@ -310,7 +312,12 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > > do { \ > > it_func = (it_func_ptr)->func; \ > > __data = (it_func_ptr)->data; \ > > - ((void(*)(void *, proto))(it_func))(__data, args); \ > > + /* \ > > + * Removed functions that couldn't be allocated \ > > + * are replaced with TRACEPOINT_STUB. \ > > + */ \ > > + if (likely(it_func != TRACEPOINT_STUB)) \ > > + ((void(*)(void *, proto))(it_func))(__data, args); \ > > I think you're overreacting to the problem. I will disagree with that. > Adding run-time check to extremely unlikely problem seems wasteful. Show me a real benchmark that you can notice a problem here. I bet that check is even within the noise of calling an indirect function. Especially on a machine with retpolines. > 99.9% of the time allocate_probes() will do kmalloc from slab of small > objects. > If that slab is out of memory it means it cannot allocate a single page. > In such case so many things will be failing to alloc that system > is unlikely operational. oom should have triggered long ago. > Imo Matt's approach to add __GFP_NOFAIL to allocate_probes() Looking at the GFP_NOFAIL comment: * %__GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller * cannot handle allocation failures. The allocation could block * indefinitely but will never return with failure. Testing for * failure is pointless. * New users should be evaluated carefully (and the flag should be * used only when there is no reasonable failure policy) but it is * definitely preferable to use the flag rather than opencode endless * loop around allocator. I realized I made a mistake in my patch for using it, as my patch is a failure policy. It looks like something we want to avoid in general. Thanks, I'll send a v3 that removes it. > when it's called from func_remove() is much better. > The error was reported by syzbot that was using > memory fault injections. ENOMEM in allocate_probes() was > never seen in real life and highly unlikely will ever be seen. And the biggest thing you are missing here, is that if you are running on a machine that has static calls, this code is never hit unless you have more than one callback on a single tracepoint. That's because when there's only one callback, it gets called directly, and this loop is not involved. -- Steve