From patchwork Tue Jun 4 12:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13685127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79DDDC25B78 for ; Tue, 4 Jun 2024 12:26:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDB496B00B6; Tue, 4 Jun 2024 08:26:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E635D6B00B7; Tue, 4 Jun 2024 08:26:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D04E46B00B8; Tue, 4 Jun 2024 08:26:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B04436B00B6 for ; Tue, 4 Jun 2024 08:26:13 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 58615160980 for ; Tue, 4 Jun 2024 12:26:13 +0000 (UTC) X-FDA: 82193128626.18.9E5AFF5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 8778E1C001C for ; Tue, 4 Jun 2024 12:26:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hFWJ6+r5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717503971; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dhRcJw45QpvZbCGtXIGpN8SLS1SogYKGihoPbbdpvvk=; b=fClFvxP3uA+6PTWpcA1LgCAOvyUNFrdVVkGScBVky4BnZnoQFNu5r/Xjvive4C3TOpAU/M oeZ/92OIWyIwZ4oMxiapV9kAr3b3lepJZzItlOmWUTs0t+qt9AiBmRbecM6dzMTPZAXipC DAlPCkk/jz7kvbp749/G4u8xKWx1JyQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717503971; a=rsa-sha256; cv=none; b=Gr8DSUiY3NHjnGptfb24amHcqKabH1hk8tWGrR9ee1ePl4IXY2J2FwqqiWzeK8789P4GuJ ZyABjF/49xuxzEPOUBLQX//kP6BP898GQSzfR45MAP/mRfoOz7pqQWHyUEJyi7e2vfKah6 UXP/hBpkbZy9gvcrtYZE/vN8DUyhz6k= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hFWJ6+r5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717503970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dhRcJw45QpvZbCGtXIGpN8SLS1SogYKGihoPbbdpvvk=; b=hFWJ6+r5L9NUMQIygz5Qg0zBSNvUAdW5O5DXmaGebpOUgacLAF8hKBExbEBllZsMNQOykb SS7lWdlBgbop1HaKHNog1DI4/fNThAX9CrQs/jPSC3xh031KKZTR7aOyJA0oR6/mqHOzNj og22FEqzLiwEoywak+J7qUCbo6FNqSM= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-thwmSiOnMeqZMJPmEBQ3dQ-1; Tue, 04 Jun 2024 08:26:07 -0400 X-MC-Unique: thwmSiOnMeqZMJPmEBQ3dQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C2F4F18BF6D6; Tue, 4 Jun 2024 12:26:04 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.118]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EADCC1955D89; Tue, 4 Jun 2024 12:25:57 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, David Hildenbrand , Andrew Morton , Guillaume Morin , Russell King , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" Subject: [PATCH RFC 1/3] kernel/events/uprobes: pass VMA instead of MM to install_breakpoint() Date: Tue, 4 Jun 2024 14:25:46 +0200 Message-ID: <20240604122548.359952-2-david@redhat.com> In-Reply-To: <20240604122548.359952-1-david@redhat.com> References: <20240604122548.359952-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Stat-Signature: 8hbmri5fhnsissdtejwhcqa6m9cgdnmq X-Rspamd-Queue-Id: 8778E1C001C X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1717503971-382920 X-HE-Meta: U2FsdGVkX19h38g+l5aln1Oq/LlzJHTD3XE7FAQO+VvzrSeg0mAm53jpsIRJHfLN5Vmd9MWmfrGZFp+g8WOIQJzOkzz4fpGjB2pPCE07zc0sXnh7+9vl+FGGCnK+GM/YU1BRA0kIHww09iKypFgpxe6gP3vicjlQUH83xjXnEkOXkURztcSwz2MplgLkrJksqpm5W/APpVN7TYEhSFgl+uX8lgSSNzMOkqbx5W+p1IX30UB3owB+beCMXI+Z+OxwzFs1BNXMvgJ95uJE6cYeD799tddxquF3Ttw9Upk/Pwv1FCOK8ILpeSTDVPAijhvr1nEZws/MDEkiJ1ZoWlVeiSBVSA50FwrAKQLPzLZGAnNPjTx1oIslKJHCgUnoT3v7JcuEjilDfFRFJE6tOo4QmDdjzHDGyaa24ME3fke2BzH5lkUwUyakUkPXT8qIYHFaKyEdWxYCiMc0RLi/pg0iygkwKS07di0hqohfIcodkBZhsX7bFEjSvMXwALOHYnCvvAGbbInB6nU+D3MLOUcrGmeLWfoDCF6jyjoc/RPPZw9bVxsgKZx0rVB0KdX487RCs2pwPizq1AztzYNsqxfDAN/JoMLRsubexcShsScKPrdBYLAFOf/kl+Ricw+qdfhmJ5PND1YWuZkcckBet7T7jftKPD+8DTznTpzk83UnX4/kIEkKyrlV1Vn2jJ0fhhrxVFksDQ1g6Nir/vQnWPuXBJVvwJfHJoYry7SOzNtqOJpxLDLq0OaH83nr8L3lXYIJXqhir0U4tLujCNt7LjKtRH0BOfMYw5fr6raVnt7MmU9nyaO8XEaZLypWjMZKxzip7YuYgO+ih35YYxkzgRp2GfW6djfa0F0Bhu/7DvAe5S7CFIbleqw/eJRcFEJfKbYQ81fqE+QzGLd1rE28Ec+vGdefJ9H5eI/+zAbjqAhw4nm+N+Wm4iKd0r6EiFceO942895hBSmN+dI5tFKnqrr wtmxiUby WqFjq5aZqBpBPeDGesgd5iFT9LO1vrh0GvP+zBBxSETzViaorNDNxBh66UTrXCpmW0OpNN995TOgzJ1toBJMo9g81QXNOZvvGw6LLl5xQ/XoxFWSmzxum+V493xakTW/C7txfJW423gM9+pVgaxEYSqIRvtKC96EByWTh5RdUhENFwIhRUA4WXKZoIIqu9/72bxPaMhyvVfyL77wJL6eEFviJTMpHoXpMZNwGu+nTGc/+nEuD4fFWDFZr+PKzL3/N2GFAB5XSabH5Ja/Np0z+Hye0omVzMLAbYGSA5Wy25ckzI1mlgnknfulfFw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: ... and remove the "MM" argument from remove_breakpoint(), because it can easily be derived from the VMA. Signed-off-by: David Hildenbrand --- kernel/events/uprobes.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 2c83ba776fc7b..c6d6b7a8e4410 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -886,10 +886,10 @@ static bool filter_chain(struct uprobe *uprobe, return ret; } -static int -install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, - struct vm_area_struct *vma, unsigned long vaddr) +static int install_breakpoint(struct uprobe *uprobe, struct vm_area_struct *vma, + unsigned long vaddr) { + struct mm_struct *mm = vma->vm_mm; bool first_uprobe; int ret; @@ -914,9 +914,11 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, return ret; } -static int -remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr) +static int remove_breakpoint(struct uprobe *uprobe, struct vm_area_struct *vma, + unsigned long vaddr) { + struct mm_struct *mm = vma->vm_mm; + set_bit(MMF_RECALC_UPROBES, &mm->flags); return set_orig_insn(&uprobe->arch, mm, vaddr); } @@ -1061,11 +1063,11 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new) /* consult only the "caller", new consumer. */ if (consumer_filter(new, UPROBE_FILTER_REGISTER, mm)) - err = install_breakpoint(uprobe, mm, vma, info->vaddr); + err = install_breakpoint(uprobe, vma, info->vaddr); } else if (test_bit(MMF_HAS_UPROBES, &mm->flags)) { if (!filter_chain(uprobe, UPROBE_FILTER_UNREGISTER, mm)) - err |= remove_breakpoint(uprobe, mm, info->vaddr); + err |= remove_breakpoint(uprobe, vma, info->vaddr); } unlock: @@ -1250,7 +1252,7 @@ static int unapply_uprobe(struct uprobe *uprobe, struct mm_struct *mm) continue; vaddr = offset_to_vaddr(vma, uprobe->offset); - err |= remove_breakpoint(uprobe, mm, vaddr); + err |= remove_breakpoint(uprobe, vma, vaddr); } mmap_read_unlock(mm); @@ -1386,7 +1388,7 @@ int uprobe_mmap(struct vm_area_struct *vma) if (!fatal_signal_pending(current) && filter_chain(uprobe, UPROBE_FILTER_MMAP, vma->vm_mm)) { unsigned long vaddr = offset_to_vaddr(vma, uprobe->offset); - install_breakpoint(uprobe, vma->vm_mm, vma, vaddr); + install_breakpoint(uprobe, vma, vaddr); } put_uprobe(uprobe); }