From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 8D8F139936D for ; Thu, 9 Jul 2026 07:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783582888; cv=none; b=lErRsOhvwUkpcuwAGKXaOsMRIaIhNuE3/I60mHP9vOMJ5QcnHkw2K6DXeXsuMV9ZBycxaR4GzINWtD7PVNJtCUwY0JI5N5SlGJgHE3H+y2xhx+5lEah9HZtc1OYnHixtmd1tNpIF+StixoZCZ9DWUYQNnln4kmO3pnEU34idFds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783582888; c=relaxed/simple; bh=xtrY4/IV1kkuKiVuakb4wYUItlYnPF71VBefCRtk66E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sv+wFlpjQM8fRvQdq2pBP9XIRWPSBymryil4aCW716gGOuoWHR9lXtJ1gxmSe1r/1od3lTXC5T8Y3chHhhY/K94gxY8AzLDdsNpc3NyEtrS03CANUAuRFwV5OOP5zrQYdXiWpkLgQgxmsruWj2vOflfkwLNBWxCjxSUb2/vtpxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Rf10VFSK; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Rf10VFSK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783582887; x=1815118887; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=xtrY4/IV1kkuKiVuakb4wYUItlYnPF71VBefCRtk66E=; b=Rf10VFSKbbVybAhMRqDiW6T2B0YMqXFWNTaBVN1NHhqSQd7F9YQlbl6H IjoIFHqA0tJdOSR1uCRldx1b4azKpwecGPpnQvjFoCYKKKt4ikexcKhKc 4JoCyBw5rtImNvmK+CEDKB/6OeifWxvOv2MVUd3olI6vHSeLvYpUbckmn 0WM3oo8w2hjbRKLgCvyXbvV7VCWaSyKFP3RZC/sjMn2M2rOkuySQWBdDf liRWeEYprCWuifi1AUIHrywiL9GH1CPDbIOpc1Y2nTC5QWk8DsyU2zzP5 9VB17qNyhwQvUv+P8XA2v716E0X+/bPI7XoBojc8tY+HQdv2ZtGRzOYvC w==; X-CSE-ConnectionGUID: Au1NZXPJQeSynHg2bP2SdA== X-CSE-MsgGUID: JDK3toHrTautUVJEdrDQOg== X-IronPort-AV: E=McAfee;i="6800,10657,11841"; a="88172546" X-IronPort-AV: E=Sophos;i="6.25,154,1779174000"; d="scan'208";a="88172546" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2026 00:40:49 -0700 X-CSE-ConnectionGUID: P2Pvc4Y/RqezAZC3ZAWjOg== X-CSE-MsgGUID: XdNurqyyS8uqswm62QretA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,154,1779174000"; d="scan'208";a="258378238" Received: from ettammin-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.235]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2026 00:40:46 -0700 Date: Thu, 9 Jul 2026 10:40:43 +0300 From: Andy Shevchenko To: Anshuman Khandual , Petr Mladek Cc: linux-mm@kvack.org, usama.arif@linux.dev, hughd@google.com, willy@infradead.org, ryan.roberts@arm.com, "David Hildenbrand (Arm)" , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH V3] mm: Standardize printing for pgtable entries Message-ID: References: <20260709044334.1741263-1-anshuman.khandual@arm.com> 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: <20260709044334.1741263-1-anshuman.khandual@arm.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo +Petr, wondering your opinion about code dedup (see below). On Thu, Jul 09, 2026 at 10:13:34AM +0530, Anshuman Khandual wrote: > From: "David Hildenbrand (Arm)" > > Bad page map reporting currently stores page table entry values in an > unsigned long long and prints them with fixed 64-bit-oriented format > strings. This is inconsistent across call sites and does not work well for > architectures where page table entry values are not naturally represented > as 64-bit values, such as 32-bit or 128-bit entries. > > Introduce a common helper to convert raw page table entry values into a > fixed-width hexadecimal string based on the actual entry size. Use it for > bad page map reporting and for dumping the page table walk in > __print_bad_page_map_pgtable(). > > Pass page table entry values to the reporting path as raw bytes together > with their size, instead of forcing them through an unsigned long long. > It keeps the printed output consistent and avoids truncation or misleading > formatting for non-64-bit page table entries. > Cc: Andrew Morton > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org FWIW, you may move these to be after... > Signed-off-by: David Hildenbrand (Arm) > Co-developed-by: Anshuman Khandual > Signed-off-by: Anshuman Khandual > --- ... this cutter line with the same effect on the email. The bonus is that it will eliminate the huge noise and churn in the commit message. Note, many maintainers switched to this schema (especially those, who use `b4` tool, which allows to handle this nicely). ... > +static void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size) > +{ > + if (WARN_ON_ONCE(buf_size < entry_size * 2 + 1)) { > + snprintf(buf, buf_size, "overflow"); > + return; > + } > + > + switch (entry_size) { > + case sizeof(u32): > + snprintf(buf, buf_size, "%08x", *(const u32 *)entry); > + break; > + case sizeof(u64): > + snprintf(buf, buf_size, "%016llx", *(const u64 *)entry); > + break; > +#if defined(__SIZEOF_INT128__) > + case sizeof(u128): > + snprintf(buf, buf_size, "%016llx%016llx", > + (unsigned long long)(*(const u128 *)entry >> 64), > + (unsigned long long)*(const u128 *)entry); > + break; > +#endif > + default: > + snprintf(buf, buf_size, "unsupported"); > + break; > + } > +} > + > +#define ptval_to_str(buf, val) \ > + do { \ > + auto __val = (val); \ > + \ > + ptval_bytes_to_hex_str((buf), sizeof(buf), &__val, sizeof(__val)); \ > + } while (0) > + > +#if defined(__SIZEOF_INT128__) > +#define PTVAL_STR_MAX (32 + 1) /* Max 128-bit value in hex + NUL */ > +#else > +#define PTVAL_STR_MAX (16 + 1) /* Max 64-bit value in hex + NUL */ > +#endif The above is quite duplicative with what we have in lib/vsprintf.c. Have you considered using something from there instead? (Yes, it might require some functions to be wrapped or dropped from static.) -- With Best Regards, Andy Shevchenko