Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2139539rbb; Tue, 27 Feb 2024 11:50:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUiXlmlnOk3Nx0tJvELEFayOginiwkagCASEjp28uX6jShZvBV/TOfwb4+KwEXV42TX09g8eop6siQRKNSvBFH6gLMdSsuZckU5dlyaPA== X-Google-Smtp-Source: AGHT+IHEFIwm4uhKaXfF2/b9r2cBENzuZckYRe7dUjyAfjWjNajuW3TmXig/skMU7/v6qYrczzaL X-Received: by 2002:a62:b505:0:b0:6e4:fddf:c1d9 with SMTP id y5-20020a62b505000000b006e4fddfc1d9mr7009376pfe.27.1709063430312; Tue, 27 Feb 2024 11:50:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709063430; cv=pass; d=google.com; s=arc-20160816; b=dgzWBk66or9AAr+NxliCyexVuulUIkvbhUj9gnsKhcOx2YwbvRAanSqqdDCxX4dL00 uddcDjxzLkUI8r87v8dEQ6YtUgDdcAn1XJkMNE/ff0eXz6Xmt01Gv0UWOrE6mbdyU9Ax 608ATxRC/oN3+QgKf7rTYFKiddSPbND7C8XVw/v1clwpX8sfvIjYFhRM1q5pA9RsrFx6 sqoEWaH/REAlmh6YZEaAbNGECAb4zS2wCiTy/+WrX1wvkRC54z86la9aJhGEgClV3Ld0 JUlESUiiET3xBFm9uyPGF3Lt8b5u/eNian2ltThH5v/tqU3y/LZzwTeehyczFFXg1Ikf WgDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UUIzM5gR8435a9CnuRQqMXVWteW52NAQFKjjcehXpfk=; fh=X0IrMXd89FyVOY97cXjg7VL3Xa86ZijpNc6UElYjGGQ=; b=BhFM6IBz9Pc/XbocbY3uAJYEzxTsFG7fTpp5yk4FISMB1yHvbdJUPOehQ3VxviQeP8 Jr5a1fSkvI3HGA21520gii0xRbeiLRtqa0v76PxlDHBTeWLnBq9ztmje0UCUEvSNkWR3 yP2oXp6sQJQUAf39hh4Z5VG8XvfW+ngXl4iErMaAamJQDcQ6ZTnJYeH0i83U2LcUCdmy 4SBCEYMQx36CXYrbQtHyRLs5ABcANVWLHoCmK3MQjN2YURijE6/9HJbBEymdirVb0Z4t HnBAkdbsiSoSDOrfBifMvdi8mZHecKopxA+6GeMabMqGZgPLEIhHHs3bqH/ASaHzPkLI 2LSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LNerlRoW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-83845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 5-20020a631345000000b005dc7e74bd95si5717570pgt.564.2024.02.27.11.50.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 11:50:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83845-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=@intel.com header.s=Intel header.b=LNerlRoW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-83845-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83845-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 DEF7E28E4B9 for ; Tue, 27 Feb 2024 18:32:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56ECA3A1B9; Tue, 27 Feb 2024 18:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LNerlRoW" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 295821E49E for ; Tue, 27 Feb 2024 18:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709058740; cv=none; b=ey6wgpeCB/V849dfqx3lX0oUj0cOTLs/ENKzEB1uDSIeGWmH2vRdswDKHhA6rS7gT5qMO54se1ItPuxe6CjUl8UpmGcK27APVyWVmQTsn3N5irXOpBbLSY0GRlt1+AGAjPdtAFgZhCFxRf3kiHx/brWaavCWiWLkICy82JC6WDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709058740; c=relaxed/simple; bh=QxMC8lWIN6vJn152m1rPforyXWdFMHJtVlYfboqMgWE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jueVbpJs/v58inRJi2HgsArrV54rXF33DUJ4ZWMdOp5b1VDNY6YJEXtgx1igo3IbGMzPtX1kVF151QEyop+lHo2BOOSdHQOuIEXiZnqqwlaQt/QU2FJEuhlKcmuJXQ7gL7IN5TJZlvTrtDno7BNKeymczssmGzFGxIcjf8rWmKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LNerlRoW; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709058738; x=1740594738; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=QxMC8lWIN6vJn152m1rPforyXWdFMHJtVlYfboqMgWE=; b=LNerlRoWlRcULwSCzW7DE6Xla7kjdXOtyMirexvJbtWrHrBfuIDsSO5r lTnmjkbCAn+70jxhOSnsbGXdiVnhGL9rNemcKG6Jrqp/CbKNgHN4VGEyQ fggYKfapw3q+0bbmScXiZDM+rnrUnRWNhTEOOUyTDj+NiOeACH9nDaJTe wr1FuCLEFpth0wcB/KNPh5dGaIM8WnpxiHc+9Av0wrMMjYaK1u7C+4BNI beo9mpve3NSArgDmSqrqUmErG2J9isfwc9y/ZXA35/0AC2ODMyKCRnbs+ ssJg62y5e/TtrZjW30PVAssKtjVCmiV0J5JVOwsFvUCD7uh318EAb5li3 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14858916" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="14858916" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 10:32:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="827770836" X-IronPort-AV: E=Sophos;i="6.06,188,1705392000"; d="scan'208";a="827770836" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orsmga001.jf.intel.com with SMTP; 27 Feb 2024 10:32:13 -0800 Received: by stinkbox (sSMTP sendmail emulation); Tue, 27 Feb 2024 20:32:12 +0200 Date: Tue, 27 Feb 2024 20:32:12 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Rasmus Villemoes Cc: Jani Nikula , Rodrigo Vivi , intel-gfx@lists.freedesktop.org, Petr Mladek , Steven Rostedt , Andy Shevchenko , Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/12] drm/i915: Indicate which pipe failed the fastset check overall Message-ID: References: <20240215164055.30585-1-ville.syrjala@linux.intel.com> <20240215164055.30585-2-ville.syrjala@linux.intel.com> <87bk83mfwp.fsf@intel.com> <1013ff2d-76b2-41f9-a5d4-39a567a3b0cc@rasmusvillemoes.dk> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1013ff2d-76b2-41f9-a5d4-39a567a3b0cc@rasmusvillemoes.dk> X-Patchwork-Hint: comment On Tue, Feb 27, 2024 at 10:38:10AM +0100, Rasmus Villemoes wrote: > On 26/02/2024 15.57, Jani Nikula wrote: > > > Personally I suck at remembering even the standard printf conversion > > specifiers, let alone all the kernel extensions. I basically have to > > look them up every time. I'd really love some %{name} format for named > > pointer things. And indeed preferrably without the %p. Just %{name}. > > Sorry to spoil the fun, but that's a non-starter. > > foo.c: In function ‘foo’: > foo.c:5:24: warning: unknown conversion type character ‘{’ in format > [-Wformat=] > 5 | printf("Hello %{function} World\n", &foo); > | ^ > > You can't start accepting stuff that -Wformat will warn about. We're not > going to start building with Wno-format. Are there any sensible looking characters we could use for this? Ideally I'd like to have something to bracket the outsides, and perhaps a namespace separator in the middle. Or are we really forced into having essentially a random set of characters following just a %p/etc.? > > > And then we could discuss adding support for drm specific things. I > > guess one downside is that the functions to do this would have to be in > > vsprintf.c instead of drm. Unless we add some code in drm for this > > that's always built-in. > > If people can be trusted to write callbacks with the proper semantics > for snprintf [1], we could do a generic Yeah, I was at some point thinking that having a version of register_printf_function() for printk() might be nice. The dangers being that we get conflicts between subsystems (*), or that it gets totally out of hand, or as you point out below people will start to do questionable things in there. (*) My earlier "include a subsystem namespace in the format" idea was basically how I was thinking of avoiding conflicts. > > typedef char * (*printf_callback)(char *buf, char *end, void *ctx); > > struct printf_ext { > printf_callback cb; > void *ctx; > }; > > #define PRINTF_EXT(callback, context) &(struct printf_ext){ .cb = > callback, .ctx = context } > > // in drm-land > > char* my_drm_gizmo_formatter(char *buf, char *end, void *ctx) > { > struct drm_gizmo *dg = ctx; > .... > return buf; > } > #define pX_gizmo(dg) PRINTF_EXT(my_drm_gizmo_formatter, dg) > > printk("error: gizmo %pX in wrong state!\n", pX_gizmo(dg)); > > Then vsprintf.c doesn't need to know anything about any particular > subsystem. And if a subsystem breaks snprintf semantics, they get to > keep the pieces. With a little more macro magic, one might even be able > to throw in some type safety checks. > > Rasmus > > [1] You can't sleep, you can't allocate memory, you probably can't even > take any raw spinlocks, you must attempt to do the full formatting so > you can tell how much room would be needed, but you must of course not > write anything beyond end. Calling vsnprintf() to format various integer > members is probably ok, but recursively using %pX to print full > subobjects is likely a bad idea. -- Ville Syrjälä Intel