Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp456339rdh; Wed, 7 Feb 2024 09:26:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTFyvK9BdMU+I5/PMMx0qCXvlgUT8nF0hvGtQDJ1vYqLUQ6dELEMDQq5eNyJ4Hpl5SP4X6LkBcfsR4GqfJPBSYhmupNIt2v7EvqgmUSw== X-Google-Smtp-Source: AGHT+IELFBMLYwHejRH98yvTDGJibX1styJOrFiCOp9DU66Sz5/Do+eOjbPqTeCWqmlAhwQz1kQi X-Received: by 2002:a05:6830:1141:b0:6e2:71d6:c2dc with SMTP id x1-20020a056830114100b006e271d6c2dcmr6607187otq.25.1707326794336; Wed, 07 Feb 2024 09:26:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707326794; cv=pass; d=google.com; s=arc-20160816; b=QZCSBm2hmVIFexQQCdRk0aGgzaRjk+jZ6KUxVUAv+rQ6QlSfvYfJqDkM6WENJc851e WeYFq+4znZnSX5+1ZSCEzba5LW2n8YyLsk+jOA/QVZ8ZQyCyl/i8RNE+sRilZasAnB+I gNnx582IOXfNm0oAt9nCYfWe6AYvPDa11mhM7YgeMd9ntvoJw0TTWMnvtoRr3PKRZx9T OceGzJhVjYCi1lFFDljT19TsVkpuNK19D/afOatTYZrxwpszkOe2/HjMvN8UN6XTkLbZ 6IeZnXdq5R1H0d05u3tEdKSgZpBlS3epi8vJE9kVbXFP0fMEPaJ+9QioWV6mzeo96Ju7 OzUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BqgWKiRZL2CC8sxFnn6V/1kA/bbRBrlDp1wF2mJHICQ=; fh=XVX4Kor09ZXlYTBrpYdbvsmUSvTEU3hndlFnwNSz/Xc=; b=R/2XpIbaYeOz6VF0oflLQDUcqdKLuD3QM4PuqGyeAoid6ciUgs7FvQZxbCUh8EJQhb f9lUGelQ3fhLtEa0AkAtTuQqsQn5IHmfHPEkw7aJPkRD5YW+L6Hpm0HIt/p46MCXT5s1 vZFmuK/tv4eS8Y3pCQgMSdj6Yv7UVr5HiyJ005On9LtjLaBMA+boJEzogQc2GQ3bTmKd ESqxslDbM1VxE9Oa21PmuBH/rV5CA5FGG9rAyXixFnyPKYIEUX1Bi+l2859VjYS5GY6E T25ACrMgrrYJI5K7fCF9l7/gJ7O8Szv1x3JF2vzwCA2mBDGsgcfKqeRo8DRfXIzehD2b 1mPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wj1uLws0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-56817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWRdwuIE7NLcZdEZnh513/TYa2gGDDwcu2i73JmQSTOOqlrxsjtdtVlrAuhukFoFuHUyNqe4Ydpda/eKlkwd65y2esTToHO1Utn7YNKAg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b24-20020a656698000000b005d553239b15si1918781pgw.493.2024.02.07.09.26.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 09:26:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wj1uLws0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-56817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8147528EC8C for ; Wed, 7 Feb 2024 17:16:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCC15823DB; Wed, 7 Feb 2024 17:16:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wj1uLws0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E27A880C00; Wed, 7 Feb 2024 17:16:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707326162; cv=none; b=ez1GFrLS7eJ72jAW6YDw0kMI2ZDOcu3L6UK6hL8oPg1NEWoNdTjm8PatY5fPioCu9hQPBqvtvFDq9PkjumTuOGLDiv93U1mXtMNnaO4G9junp1xUE6syD3sBLm/laWWLzrlTXf6IeZbm6OBScUrEWpzlw7u8/f50hxZZWKt48jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707326162; c=relaxed/simple; bh=YEJtTqT8spDDKxLpGC2lvI8xDbQGR7mItvjQxB6zfts=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=F8hGyyO9dtG1jx+VWnBEpaerEYs0rAqFHiGO8R8bvkjumT3HtrFgT0aAY2qAwArRCUoxSAmLG6ipN7K7s1BZ+9jLIx+b6XCE3ibkrlOBf8QjsdMVFQPTTAIVU8Xpk3c7lJyjwZMi2VeegOGqpOV9R4ZG8JaoWRzHKbfW1EYBiOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wj1uLws0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B482C433F1; Wed, 7 Feb 2024 17:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707326161; bh=YEJtTqT8spDDKxLpGC2lvI8xDbQGR7mItvjQxB6zfts=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wj1uLws0RC5NTlAAelSW0K6IgDYt7hiw+JS+k6T2vzM6OzXpxw7D1K7pfzQQtgAp7 gOyJEAYvfCbaFNXKD476/2IAyYmRyPxZGa/sVTDqQ0w2u6zIIUEbkowN+jaO3GOK+m zzkjXYRuYcmqNnOYgdpDTG1JvU6UvHx0A4x1Da+ZWn2hkj59N3/HjRSzhav6TkICqg qyQP9gMoNJ4V+mHbKLjioF7InzSSQ9yzWcahc3fUHEUflqap4epCiX/jvSMHJG+9G5 sD8r3ZJx/EFSPTVRJMW2kjx4SY9x1wN57tgmG6PC/pzyQv2PEHyI1VQymoHyrrI/i1 Z5Qyi5Vv5QOsg== Date: Wed, 7 Feb 2024 09:16:00 -0800 From: "Darrick J. Wong" To: Miklos Szeredi Cc: lsf-pc , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [LSF/MM/BPF TOPIC] tracing the source of errors Message-ID: <20240207171600.GC6226@frogsfrogsfrogs> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Feb 07, 2024 at 10:54:34AM +0100, Miklos Szeredi wrote: > [I'm not planning to attend LSF this year, but I thought this topic > might be of interest to those who will.] > > The errno thing is really ancient and yet quite usable. But when > trying to find out where a particular EINVAL is coming from, that's > often mission impossible. > > Would it make sense to add infrastructure to allow tracing the source > of errors? E.g. > > strace --errno-trace ls -l foo > ... > statx(AT_FDCWD, "foo", ...) = -1 ENOENT [fs/namei.c:1852] > ... > > Don't know about others, but this issue comes up quite often for me. > > I would implement this with macros that record the place where a > particular error has originated, and some way to query the last one > (which wouldn't be 100% accurate, but good enough I guess). Hmmm, weren't Kent and Suren working on code tagging for memory allocation profiling? It would be kinda nice to wrap that up in the error return paths as well. Granted then we end up with some nasty macro mess like: [Pretend that there's a struct errno_tag, DEFINE_ALLOC_TAG, and __alloc_tag_add symbols that looks mostly like struct alloc_tag from [1] and then (backslashes elided)] #define Err(x) ({ int __errno = (x); DEFINE_ERRNO_TAG(_errno_tag); trace_return_errno(__this_address, __errno) __errno_tag_add(&_errno_tag, __errno); __errno; }) foo = kmalloc(...); if (!foo) return Err(-ENOMEM); or if (fs_is_messed_up()) return Err(-EINVAL); This would get us the ability to ftrace for where errno returns initiate, as well as collect counters for how often we're actually doing that in production. You could even add time_stats too, but annotating the entire kernel might be a stretch. --D [1] https://lwn.net/Articles/906660/ > Thanks, > Miklos >