Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2879365lqp; Mon, 25 Mar 2024 11:48:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlDas4iiO4p3xLwOiNP9xDvARcSBXPNYyZW9syiLO/GoxEB3ACkOY6P6I0chXjx0iRvTL7NNWvmcNCOkBjDo2OGSAj0v2h1C9UU1YVjg== X-Google-Smtp-Source: AGHT+IFoEqwLKgQiTr5rRTNRaZzUnJ1OXS+H2p/vrcr+wdZgzyJECSBFPyLyTkCN+rjN+fNy+Sg1 X-Received: by 2002:a05:620a:2482:b0:78a:54c6:7418 with SMTP id i2-20020a05620a248200b0078a54c67418mr5223868qkn.12.1711392490309; Mon, 25 Mar 2024 11:48:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711392490; cv=pass; d=google.com; s=arc-20160816; b=A/CCbNbjuxphCDQMUHr3jLi0GkFUmMl/2083xrVkydud5UhxclIIC0KGTMTZXpRP8M 95k1ASpzIAPRVVCR23XsDY7C7hd4Rp/dHly2knwlpADmdR3cHLR6+hNHfZqvwjktYRv/ L5Ua3SiJ7bon3ZVwSjgzUlvdrUqihNbm2tIGRPbeXN+KgZSj5m7xu/i0mBL+wtxMqaV0 oZZ0o8bU13+Nat9B+8rsbn6AQWp6ykKZTS+t/0SFAmS6pUTwPyavqzSCqrLnA01yLWO6 SsVxrfqEImbpZsu/pe+8fEAWXLl1F+qpE0wLdfDfdBaBdz68fHJdZZSECAsxpg1UgPzx 2KDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=Sh4Dr7qEFzy+UIH7DQyLu3gr/mznmeroCNZR2VAUEJA=; fh=b4g2Uh3boAsgkN3YByDviJQ13n/cW6NCiAh8X/bUzFY=; b=XNnQK6ATJIXlSuNntxg8aEvfxQW8eXE6b4K7MFRFqqfD6HyEjPwtgN2DBkKfGN1XZH /4CYw+cwv/S71UKeaiVJTqsb+MjWQq16zlshcGcVIt8Tx6hc3UzmrBge4DVyPzyOeGUY efmwRzUncHhtIZii6CDX3Y/48zWJKdIhAb6OAxJJa10PUTqSClHN+uhYkMVKWKhjfOfa G5stXv0ucaUJs0BuYkbdG/uL7vMvZenWyb+5+wm5sHpyM6TQze2wcb+vBXXddyevGcJf ghKQlrihz+ByMF2Mg4Y6Swp80zrZnk4Bh3lJLVpi9fC3K94jU/i0dLjflgbygbJwaGLg zPxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UGOCOCHp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117726-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id cx13-20020a05620a51cd00b00789e7ef11f9si6054068qkb.586.2024.03.25.11.48.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UGOCOCHp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117726-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117726-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0103C1C29162 for ; Mon, 25 Mar 2024 18:48:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 563303C6A4; Mon, 25 Mar 2024 18:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UGOCOCHp" 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 7DAEEBE4D; Mon, 25 Mar 2024 18:38:00 +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=1711391880; cv=none; b=iNLz8vUStuCxBhK7DX7760ywhx9NMKgoxaP0Iqvi7+kEHI/Bha4Oi62bCQUrGSeoVV9FX5MDhsB1bSra8VVpwI25bDq69ZLGERpy5Sl2tJnPa4azNmXznwa8h7xsJ/EeuyFPQbddKVBIH4iyhOKyIxV6kFdnMB+4QTk8Z1oDaCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711391880; c=relaxed/simple; bh=NZ8ILajyJZp/6r5YApASYz0CQF3HAtXJb6AdZAZRbOo=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=NuJjoZBjw8NPk+zsdVOiSxqO+Lw+dm0Wd3ELYP2pnkJtey8tBOBaZh/jq1iTbtRVM0IB1ywvJvuH41HRalIPpR15adUtE74gvXJ2mfaBLUCxCbVvkHw4sA21YBTk3vqhTrtuhNFZrboGNj0wrZueqBOMeUeX96zQ7Nh4ox91Few= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UGOCOCHp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0425C433F1; Mon, 25 Mar 2024 18:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711391880; bh=NZ8ILajyJZp/6r5YApASYz0CQF3HAtXJb6AdZAZRbOo=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=UGOCOCHpMLkpa5Zvpv7VOcuZ7OqMfLSKGY85IkyeCkgXdaBN3pemZspl5hbiqRYa2 OEFMiZh8+aPVRnzje21rJKhYJMuQY/z8vSI7LaqDQUbcaOgh+eH5JHGnJ0reer69nn y58IyiOAX423nM+ROQA2AN4TBX0pokhb/Q3dtsiHXpb5NfMfqrvX1wakxqwkOCfHdU hE3a+bXeXfcEvGI8z/luv61oCEO/e2U9/A8i0zTz/QAAAxnaq0e/iKEynVu+AAdG1E mu416QkmS6HZ2+VYNv5kWqg5RXCmfxR375M2l3DPWLjoL8U/t7H8XpTqynCN7iVeAu oKX2/6VvQK8Xw== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 25 Mar 2024 20:37:55 +0200 Message-Id: To: "Masami Hiramatsu" Cc: , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , , "Naveen N . Rao" , "Anil S Keshavamurthy" , "David S . Miller" , , "Calvin Owens" Subject: Re: [PATCH v2] arch/riscv: Enable kprobes when CONFIG_MODULES=n From: "Jarkko Sakkinen" X-Mailer: aerc 0.17.0 References: <20240323232908.13261-1-jarkko@kernel.org> <20240325115632.04e37297491cadfbbf382767@kernel.org> In-Reply-To: <20240325115632.04e37297491cadfbbf382767@kernel.org> On Mon Mar 25, 2024 at 4:56 AM EET, Masami Hiramatsu (Google) wrote: > Hi Jarkko, > > On Sun, 24 Mar 2024 01:29:08 +0200 > Jarkko Sakkinen wrote: > > > Tracing with kprobes while running a monolithic kernel is currently > > impossible due the kernel module allocator dependency. > >=20 > > Address the issue by allowing architectures to implement module_alloc() > > and module_memfree() independent of the module subsystem. An arch tree > > can signal this by setting HAVE_KPROBES_ALLOC in its Kconfig file. > >=20 > > Realize the feature on RISC-V by separating allocator to module_alloc.c > > and implementing module_memfree(). > > Even though, this involves changes in arch-independent part. So it should > be solved by generic way. Did you checked Calvin's thread? > > https://lore.kernel.org/all/cover.1709676663.git.jcalvinowens@gmail.com/ Nope, has not been in my radar but for sure will check it. I don't mind making this more generic. The point of this version was to put focus on single architecture and do as little as possible how the code works right now so that it is easier to give feedback on direction. > I think, we'd better to introduce `alloc_execmem()`, > CONFIG_HAVE_ALLOC_EXECMEM and CONFIG_ALLOC_EXECMEM at first > > config HAVE_ALLOC_EXECMEM > bool > > config ALLOC_EXECMEM > bool "Executable trampline memory allocation" > depends on MODULES || HAVE_ALLOC_EXECMEM Right so this is logically the same as I have just with ALLOC_EXECMEM added to cover both MODULES and HAVE_ALLOC_EXECMEM (which is essentially the same as HAVE_ALLOC_KPROBES just with a different name). Not at all against this. I think this factor more understandable structuring, just "peer checking" that I understand what I'm reading :-) > And define fallback macro to module_alloc() like this. > > #ifndef CONFIG_HAVE_ALLOC_EXECMEM > #define alloc_execmem(size, gfp) module_alloc(size) > #endif > > Then, introduce a new dependency to kprobes > > config KPROBES > bool "Kprobes" > select ALLOC_EXECMEM OK I think this is good but now I see actually two logical chunks of work becuse this select changes how KPROBES kconfig option works. It has previously required to manually select MODULES first. So I'll "select MODULES" as separate patch to keep all logical changes transparent... > > and update kprobes to use alloc_execmem and remove module related > code from it. > > You also should consider using IS_ENABLED(CONFIG_MODULE) in the code to > avoid using #ifdefs. > > Finally, you can add RISCV implementation patch of HAVE_ALLOC_EXECMEM in = the > next patch. OK, I think the suggestions are sane and not that much drift what I have now so works for me. > Thank you, BR, Jarkko