From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F20E40DB55 for ; Tue, 11 Aug 2026 09:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786438969; cv=none; b=ncRSdfUYZScF9lT+y8rNSvG7lDwnl6aBisxoNV9hbAQEYDCoJtkI15zvukx1hjibgoS6ApMQEcU8sEWvbNHs9DzFgUA7FvgNNG9FfvfWsxNsP6RCw7cSaz6Po54lbzKkhFLzZ/AqKdp+yngFgzSor16gs1/rdSjXiWPOuoNyiLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786438969; c=relaxed/simple; bh=UNdShtdhmtajLCAjGkTFht9aSZ4+5TfV85KWo3ksl+Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FMH/tpO8Q4+AaUKX6K2enCsC0fULGoZcRYM/RJUwkkHqGaTZHmO/A9XLz/mfX5R0HXsSQoZkglDGo1aPqQR2lmIYzv0J3MYiRkLQtg2AqshvJX/zIChQ4DP1otxFXiKmneEjPHyIRsv9TQxmLzEoP6amfcrmQPbsR0E/u5+hFsY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zmMDs8p1; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zmMDs8p1" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4813ea321cdso510695f8f.1 for ; Tue, 11 Aug 2026 02:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786438966; x=1787043766; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oJ88OLZKf9QMZYTUIDUM+DdXOTb/AyphVnNJxcq65aI=; b=zmMDs8p1h97Dkny2bIuQp1WJ+p5UwnVpcQ5Ne4Vn2F+m1l0rlqydxW3q0Rzb30eHso g94Cwe/By4wlnMQ1HaUMAB95yFPRIGYx9vGsADAUwAbScYJos7d5GjY/5ntEuZ0DKBZK ixVjtvhE6rd/aQV20LpmWymrdUsOZyQRRwH5d6QIVloS7ELmi4925+tSHsiYb+SYX4cH XnAdccX6FJMPRH35K4JB7etmsQ9NYehFnHueVVqcSh7BDiFsnfzJU/ozFBT5XvI8g/EU AKcb8hxoNwbX3uhh3RdNb8ccxkD8dbGjjh9jvEveCCR+TWh6nYxbCRXkfvMCIBe6uu0y z2FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786438966; x=1787043766; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oJ88OLZKf9QMZYTUIDUM+DdXOTb/AyphVnNJxcq65aI=; b=IiuiwJUoOgELDtNl9Dom8cf2lKMIwP/JfCmu0xux3TOJa5aI54rMUvrEuXy8ZUA/nX syg/gLP0bVpTix2j901agda+X72/zROhuA26GhtZ69qFDSQ+tLaThELTw5UlrsA7qFup 1cUI7u7tWISEug1upY69PQwJI9fcDgGBt4+A2mj4N8iQam1DRpT+H4+jdtxzphThQ+ln D7ghIRD9q2VoOJWn3LuopnnZHMZcsrZM3NDUO3K3PsP4fDJGENxZhlWIQ8kGXUGuz9UH UH2SPLfoK9/wh2mkD8vp1cTrhyIXmTVwxg25J2oDaXzPn+xcce54UIacmrVAGvJLG+8v jfhA== X-Forwarded-Encrypted: i=1; AHgh+RrZlXUkek4MhbfINcuExmYpcNwgQoKVhj+HuYz03yCH70eqSA+xpy17yaS9WWGHJTDyGjFY6gzkCxnUEiU=@vger.kernel.org X-Gm-Message-State: AOJu0YyMubKABqCNNhHhCOgD51JD72M5W+zK5N4+4+KN9768Ilc6qvpi lIJCfjSC/rUv+IRlEvNvMob44lROAcSSdnFbOS2i0Excb7ootW/pt76dFl++xOKgEKYx0z2BVc3 c/aAc5Ek= X-Gm-Gg: AR+sD11+VKbIzDuFBvhwT7KVFsb0x3dbALz9d8EFH7Yzv/hjzCtcDPl2Bbrx9pEHaha b/G69WXj8DVscg8DkYIifEKTTVrM/BvrdIMvshjIw7dKb7IQN6lDRE2/7vPxlRM/hZqm96ebIVs vZQqe926Hq8XzmwhQaa0Qgcmw+OkIA4pyp2GCY0SrckCK93ISS2wseooexVvl0fzRCR9wa7BYGs tvrpoVooYw9pXs7VYR/0LgizMfkVBAT4rhTfM4Y8hb0qhI4EqAdLn4TUFItqF4MvAhu+lmPkbdB 4goxkoCCtY03X5yEIPyDUaPFd6ts+pQVUAQvXR+WHp1QrXcKUdRXUOGp7OXo4Smf+7p5tYRSZuC 668wTuk70xneM9s+ZxCx+fVMLN+QZQ6pZBQDilv2gp5SCM8S7KAmAtoi6E1sYqBbvRXp8f9rPHq WZgyQH9Ub8saTi2/wfcptSwX0Aqs0O9JazYM4qrCqubK6Qm55rfruPtwKnhUvqYM5m3VY= X-Received: by 2002:a05:6000:46ce:b0:474:bbbb:bf17 with SMTP id ffacd0b85a97d-4814b54d77bmr1881469f8f.0.1786438965631; Tue, 11 Aug 2026 02:02:45 -0700 (PDT) Received: from [192.168.1.3] ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4814a709624sm3106323f8f.22.2026.08.11.02.02.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2026 02:02:45 -0700 (PDT) Message-ID: <8c8f6c2a-8fc2-4181-87fa-e64101dfce6f@linaro.org> Date: Tue, 11 Aug 2026 10:02:44 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] perf: arm_spe: Prefer large AUX mappings To: Leo Yan , Will Deacon Cc: Suzuki K Poulose , Peter Zijlstra , Mike Leach , Anshuman Khandual , Mark Rutland , Tamas Petz , Tamas Zsoldos , Michiel van Tol , Dev Jain , David Hildenbrand , Yabin Cui , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org References: <20260810-perf_aux_trace_large_granule-v1-0-03306c9339e3@arm.com> <20260810-perf_aux_trace_large_granule-v1-2-03306c9339e3@arm.com> <20260810174159.GC15499@e132581.arm.com> Content-Language: en-US From: James Clark In-Reply-To: <20260810174159.GC15499@e132581.arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/08/2026 18:41, Leo Yan wrote: > On Mon, Aug 10, 2026 at 04:10:48PM +0100, Will Deacon wrote: >> On Mon, Aug 10, 2026 at 03:44:42PM +0100, Leo Yan wrote: >>> Commit 18049c8cff9c ("perf/aux: Allocate non-contiguous AUX pages by >>> default") made the AUX allocator use order-0 pages by default unless a >>> PMU explicitly asks for contiguous allocations. >> >> But that commit specifically calls out SPE as benefitting from >> non-contiguous pages: >> >> "For instance, ARM SPE and TRBE operate with virtual pages, and >> Coresight ETR allocates a separate buffer. For these PMUs, >> allocating contiguous AUX pages unnecessarily exacerbates memory >> fragmentation. This fragmentation can prevent their use on >> long-running devices." >> >> so why doesn't passing PERF_PMU_CAP_AUX_PREFER_LARGE reintroduce the >> problems that 18049c8cff9c was trying to solve? > > The question is how "allocating contiguous AUX pages unnecessarily > exacerbates memory fragmentation." The relevant information I could find > is [1]: > > "On Android, we collect ETM data periodically on internal user devices > for AutoFDO optimization (for both userspace libraries and the > kernel). Allocating a large chunk of contiguous AUX pages (4M for each > CPU) periodically is almost unbearable. The kernel may need to kill > many processes to fulfill the request. It affects user experience even > after using PMU." > This sounds like it could be an attribute to perf_event_open. We can do PREFER_LARGE by default for performance and fewer discontinuities, but on Android or small systems users can enable an option to revert back to single pages. Or can this bit be determined at allocation time: "The kernel may need to kill many processes to fulfill the request"? If this memory pressure exists on allocation then do it one way, if not do it the other way. > We might have missed chance to clarify how the fragmentation issue > occurs in the first place. Let's say, a phone with 8 CPUs, allocating > 4MB per CPU requires 32MB in total, which is a relatively small > portion of 4GiB or 8GiB of RAM commonly found in phones. Moreover, once > contiguous pages are freed, the buddy allocator can coalesce them > again into buddy list. It is not obvious to me that PREFER_LARGE > directly causes fragmentation. > > One case where AUX allocation could exacerbate fragmentation is when the > system is already fragmented. If a high-order allocation fails and the > allocator falls back to smaller-order blocks, those allocations may > consume free blocks scattered across different buddy regions and make > subsequent high-order allocations more difficult. > > If this is the main concern, I'd suggest using a smaller AUX buffer > (e.g. 1MB or even 512KB) for TRBE/SPE to reduce memory pressure. > Snapshot mode '-S' could also be considered, as it allows the buffer to > be allocated once and reused for subsequent recordings by signals. > > OTOH, using only order-0 pages can significantly increase TTW overhead > on the trace path and lead to overflows, we observe this causes huge > trace discontinuity. In the end, we need to trace-off the fragmentation > concern against the trace discontinuity. > > Thanks, > Leo > > [1] https://lore.kernel.org/lkml/CALJ9ZPNLgEBxOmDim-vztUknEETwdL-Z2gJ8K9s44TiPgKZgHg@mail.gmail.com/