Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp66811lqb; Tue, 4 Jun 2024 05:26:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSNvcs/2bDEbKCDGFdiOX3+Bt2IS7XEncQWpkgsKAw5CoDD40L00L6o1fd7dEa4crC24cLb5rfnnwUroltBfOMKdUix4FSRCvQVkhUuw== X-Google-Smtp-Source: AGHT+IEbrB6pFtaN0zA+7CIBtCDHKXh6F4GtmBkszPLCIyhiImeg6W5B9IsUWsvlC5W9Bror3uP8 X-Received: by 2002:a05:6a21:150b:b0:1a7:186:f976 with SMTP id adf61e73a8af0-1b26f275a2cmr12177145637.40.1717504017794; Tue, 04 Jun 2024 05:26:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717504017; cv=pass; d=google.com; s=arc-20160816; b=Xv/5ZuJPeKlruNcEsyWaSPAWsgkl0ztGKjiL4OZxagA+akN3Q+a0rjkjWu/fYKJyA4 9RJGemZxN/fuaQakKMcqCEwEWZAVthc7Sxh7Q2+L29bnRSaXjUPlzab23eoLiJ/Pn5tr 0eKLnx/okDy5fkkoFa6ibjBn5PLWnM5qBWrfmwFCIB8BCq+3e2Uuey4OXBULUeK5y6dX rqbImEyFCEwq9wiaYaZVGT3lORL/B1q3mfPgfJWzmqWw7llAf5snq8j3fBuJVfh+FJ8X 70zn+EGMum7HGWHhx5TaQfo0pU6/WTYRRWXYNwWs1XqcwjCAxooPrpi9GzFrfDPVs0MJ X0oA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dhRcJw45QpvZbCGtXIGpN8SLS1SogYKGihoPbbdpvvk=; fh=bErpqbe/QYEePH3oTiOqYcEHAYExy7B/Y1zmYNPuOWc=; b=rEjGGR2Gz2xpRopoayG7n6ajQteYS73UHOPm+r3P6MjxbvZHIwysc6F8a493RxzCiv NRdsOmo7eV/NPriWYXs9wvpbmuGF7J30ci8eLjOnQQfGKNlsfEhxVGF3tFBWs26CFDPQ 6oGJ0I3F5pbn1bmqdB3rZOOplxBOvYJ3K8i4hg0xjJvE0OjCN5pMfO6p6YeecW+ZVzaj 7tCGGJBnacb3yW9SGZlihlIjnHn+9WhBgz1uJBefpYTXlRmWflBIyKA9ql/9n0SvuO5P xHbJinbPNqMmHvgm8qBxb0fYLj6nEXdyaWJ2S2yEw5S8brpXTxQ6o0+NoEymsBxZHYMU uKyA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PBFhD2if; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-200585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3540facd1si8064872a12.85.2024.06.04.05.26.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 05:26:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200585-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=@redhat.com header.s=mimecast20190719 header.b=PBFhD2if; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-200585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 CA5C728495D for ; Tue, 4 Jun 2024 12:26:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CC711465A7; Tue, 4 Jun 2024 12:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PBFhD2if" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 BC94E146013 for ; Tue, 4 Jun 2024 12:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717503972; cv=none; b=eKf+3uGnrNrlf1iXpO85Sz/r7f05F9aWfxL9hr1OyafVEdfC6R3zKmXhq0wCmsSZ9dfHtyUdHIyPILsDACkJWreMxkehaVVA4xD7yi1NYQmt+jLegWXA6N/tY7QvpC+FpcM72yfUTz0OE8JG+OJ0FHsuR2OWcpidIqEUIChENZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717503972; c=relaxed/simple; bh=RnX2Bqgi75oqU4Ep8dc64cWv5voqo8iAjpPhfiVlve0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XyCpZ1VJSiq964JQ9JVpDP0tAbEj2UqytSy5hWvdaHaG1hvh8w9mXZjuCba1VPUGUMX94t3YysKslhloqBQ/yuxHh9Si12PpbD0olGTyiWCIaaIDX5A2ZcMjhUQJMwR0/fa0addR8VuRS2v55dhMAN6IvCvYqTezEUPC9oqwH90= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PBFhD2if; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717503969; 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=PBFhD2ifWsBxm7BkZWeaLAywf6YAZkzb8cmGkdoyjjQ17+cyajkhg5O/m2IiK46jK2yIn6 Lxr2t3tOSirkBxDOM8MfV+zrL7sxJBIYx/hUOABjvfi4lUTdqt+7e9ARe39YJPQJ2mv1Gd 3kbSyYczHmxrZecbxYFmGrv25ysBnbE= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 ... 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); } -- 2.45.1