From mboxrd@z Thu Jan 1 00:00:00 1970 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 236DB1DAC9C; Wed, 16 Oct 2024 14:10:05 +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=1729087806; cv=none; b=KMm5RM2luqr9obedx+vjRsIi4zhhIy1qKlOc6fWgh6RQf0OjfKZ/icLnoGRMszw0jplOR20Ve4OojeWZ4Yjup/s+d1e/j9MwdT0vf7Ynz8zMGfG/H29IYSd6V9MpxOhQvObI+wQyBZDT9zXuX6lkjDEYLbeYYzWTQcHGscL8I+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729087806; c=relaxed/simple; bh=X/tEEDsGfLTMHjhr3LF9eAdGJNQDfr/bv5t1Y7vkSEY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SegBlVgCTV2oZA0o2flGosFWHAwr7ro1VDu4u6iNNKDKVX2jXpyDGi2OfavydIqGF3rhEEFcCpEZp58+vchD9uFsgI0S9SVXrgLOX3armpLAJywi3Vjd6o7i9Vh4lwoQ4rfO3vDtoMtNz0cJdu+gypNmosJyVpQhhCF/Jr0gDb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C57F4C4CEC5; Wed, 16 Oct 2024 14:10:01 +0000 (UTC) Date: Wed, 16 Oct 2024 10:10:22 -0400 From: Steven Rostedt To: Sven Schnelle Cc: "Masami Hiramatsu (Google)" , Alexei Starovoitov , Florent Revest , linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Alexei Starovoitov , Jiri Olsa , Alan Maguire , Mark Rutland , linux-arch@vger.kernel.org, Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Mathieu Desnoyers , Andrew Morton Subject: Re: [PATCH v17 11/16] fprobe: Rewrite fprobe on function-graph tracer Message-ID: <20241016101022.185f741b@gandalf.local.home> In-Reply-To: References: <172904026427.36809.516716204730117800.stgit@devnote2> <172904040206.36809.2263909331707439743.stgit@devnote2> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 16 Oct 2024 14:07:31 +0200 Sven Schnelle wrote: > > +/* Return reserved data size in words */ > > +static inline int decode_fprobe_header(unsigned long val, struct fprob= e **fp) > > +{ > > + unsigned long ptr; > > + > > + ptr =3D (val & FPROBE_HEADER_PTR_MASK) | ~FPROBE_HEADER_PTR_MASK; > > + if (fp) > > + *fp =3D (struct fprobe *)ptr; > > + return val >> FPROBE_HEADER_PTR_BITS; > > +} =20 >=20 > I think that still has the issue that the size is encoded in the > leftmost fields of the pointer, which doesn't work on all > architectures. I reported this already in v15 > (https://lore.kernel.org/all/yt9dmsjyx067.fsf@linux.ibm.com/) =46rom what you said in v15: > I haven't yet fully understood why this logic is needed, but the > WARN_ON_ONCE triggers on s390. I'm assuming this fails because fp always > has the upper bits of the address set on x86 (and likely others). As an > example, in my test setup, fp is 0x8feec218 on s390, while it is > 0xffff888100add118 in x86-kvm. Since we only need to save 4 bits for size, we could have what it is replacing always be zero or always be f, depending on the arch. The question then is, is s390's 4 MSBs always zero? Thus we could make it be: static inline int decode_fprobe_header(unsigned long val, struct fprobe **f= p) { unsigned long ptr; ptr =3D (val & FPROBE_HEADER_PTR_MASK) | FPROBE_HEADER_MSB_MASK; if (fp) *fp =3D (struct fprobe *)ptr; return val >> FPROBE_HEADER_PTR_BITS; } And define FPROBE_HEADER_MSB_MASK to be either: For most archs: #define FPROBE_HEADER_MSB_MASK (0xf << FPROBE_HEADER_PTR_BITS) or on s390: #define FPROBE_HEADER_MSB_MASK (0x0) Would this work? -- Steve