From mboxrd@z Thu Jan 1 00:00:00 1970 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 A8AADC433EF for ; Fri, 10 Jun 2022 13:48:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E99246B0174; Fri, 10 Jun 2022 09:48:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E47B96B0175; Fri, 10 Jun 2022 09:48:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D37858D009C; Fri, 10 Jun 2022 09:48:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C5F2A6B0174 for ; Fri, 10 Jun 2022 09:48:38 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9C97520488 for ; Fri, 10 Jun 2022 13:48:38 +0000 (UTC) X-FDA: 79562456316.17.8AB5A7A Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf05.hostedemail.com (Postfix) with ESMTP id 4659710000E for ; Fri, 10 Jun 2022 13:48:38 +0000 (UTC) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-3137eb64b67so71302637b3.12 for ; Fri, 10 Jun 2022 06:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=XwTm2wEFcPzM9otUDKYTRibEvpUn3l/6ZogWvW+AFbY=; b=a/DDq8tlGMDbAGV3qmEghrGw7Mwhg03Veu8NFNqQmFEYEUL5YRpnwK7cElEpAZzH4t 9qsaaQiABUQ/vYBmhMhYC8knQ6rUxptG3/U/PQkPyfgaA/A7JwOHUR2mj5Dh3uuurfYv ThOn8VCUVub2hmJCg/iyCmF9AuUHkVVz+whrv4BcBZw0rrJlvOi1PSTmaV1bs+HifLlC OWPjiiH/6O1+5wlbDJnNqgfbahu4iR/BbsS87bIth7QCDQt7DJ8fW6QDG25b6yymHzfV 5i0hbi+TaygGshkTFQE8alT+OE3n0HAU+lJOvDaaYXW+XtkhL+SheBQMGSroNz1GMApj NHFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=XwTm2wEFcPzM9otUDKYTRibEvpUn3l/6ZogWvW+AFbY=; b=V4KMNAk7inib2xHqsziw+2dJxkpvSI95ym+xMjCXV6AbC4vdxTH9o23t4QfYWsNU15 Uuumw+WZJkSpTv+pBZm9tX85ITldCHCo1FKaKJvhoUYpqWqDreX9l0gM/Fqm+VWPCMX8 IYR6UFJofpLkiVq7sK8nAsih7AKbtLYl5AXN1wtZNZiZSQUTaO063D8O4UqPZfvni1MJ mldeatYIW6/NmEMv75iVHysUvnu9rVJLXZy8kOsD29drzCyOI5wQQH2nGltrIyO5Wew+ weUgunBG/Vg1d1jlxPoVokxxM5B0+y/PS1FRLGR+39M6ps/j6cleosv4TOuptI3dmK1s mvqQ== X-Gm-Message-State: AOAM533kFmAmibJQn/dU+h+srgeaXs5NoeV0inRFQUmn8Eqk7Z5QERh4 jFUHJgY+lmM9Hf1Rm4T2Fvi53DWpwSkVDltjBlgZJA== X-Google-Smtp-Source: ABdhPJwfNs16uySnE70fDRtkWMXwYd1E0PUX0Uc2tr4CEOsmC9YIf2x1vFsCOcvzh1S5ZzMwVcLoE5j+UGeMOMRXp44= X-Received: by 2002:a81:fe0b:0:b0:30c:7e9c:701 with SMTP id j11-20020a81fe0b000000b0030c7e9c0701mr47839419ywn.118.1654868917363; Fri, 10 Jun 2022 06:48:37 -0700 (PDT) MIME-Version: 1.0 References: <20220607120530.2447112-1-tarumizu.kohei@fujitsu.com> In-Reply-To: <20220607120530.2447112-1-tarumizu.kohei@fujitsu.com> From: Linus Walleij Date: Fri, 10 Jun 2022 15:48:25 +0200 Message-ID: Subject: Re: [PATCH v5 0/6] Add hardware prefetch control driver for A64FX and x86 To: Kohei Tarumizu , Mel Gorman , Linux Memory Management List , Michal Hocko , Andrew Morton Cc: catalin.marinas@arm.com, will@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, rafael@kernel.org, lenb@kernel.org, gregkh@linuxfoundation.org, eugenis@google.com, tony.luck@intel.com, pcc@google.com, peterz@infradead.org, marcos@orca.pet, marcan@marcan.st, nicolas.ferre@microchip.com, conor.dooley@microchip.com, arnd@arndb.de, ast@kernel.org, peter.chen@kernel.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, Paolo Valente Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654868918; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XwTm2wEFcPzM9otUDKYTRibEvpUn3l/6ZogWvW+AFbY=; b=jVoArpiq8/u/pYTWN5MRVF/s92qW4ChRFDYZK0tPd+k2CVK5d7uTBOHP8LfYEh+Mgwn1Hs MqCJJbbpXYb0GWtB8ojDYST/Pl9xnGQe++K2o/bA69dRq3ck86DL59+rtrr1sJDENL71kk X8SMM7ToHlRQi9vpzEelnxctxwoN2+Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654868918; a=rsa-sha256; cv=none; b=z+Bnh6AnpEUKZ9DP8vdmDy7J7b+TYX1BseyzzyU8OFwvPOo784uCu8j07/YMkpeB1GKned S0CyJYFNlr6G2fPMGbAxEnVfgIIFACxOr1l/3XkSt70N7ZgIBtqxZQpDAJQSbIGjO1BO3r nds3XEGF889LCcV9j1rlE2s/Bm/DFCk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b="a/DDq8tl"; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf05.hostedemail.com: domain of linus.walleij@linaro.org designates 209.85.128.174 as permitted sender) smtp.mailfrom=linus.walleij@linaro.org X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b="a/DDq8tl"; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf05.hostedemail.com: domain of linus.walleij@linaro.org designates 209.85.128.174 as permitted sender) smtp.mailfrom=linus.walleij@linaro.org X-Rspamd-Server: rspam03 X-Stat-Signature: k8jgq66ake6ndiy1dypkxfwmrz39upro X-Rspamd-Queue-Id: 4659710000E X-HE-Tag: 1654868918-683875 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: On Tue, Jun 7, 2022 at 2:07 PM Kohei Tarumizu wrote: > This patch series add sysfs interface to control CPU's hardware > prefetch behavior for performance tuning from userspace for the > processor A64FX and x86 (on supported CPU). OK > A64FX and some Intel processors have implementation-dependent register > for controlling CPU's hardware prefetch behavior. A64FX has > IMP_PF_STREAM_DETECT_CTRL_EL0[1], and Intel processors have MSR 0x1a4 > (MSR_MISC_FEATURE_CONTROL)[2]. Hardware prefetch (I guess of memory contents) is a memory hierarchy featur= e. Linux has a memory hierarchy manager, conveniently named "mm", developed by some of the smartest people I know. The main problem addressed by that is paging, but prefetching into the CPU from the next lowest level in the memory hierarchy is just another memory hierarchy hardware feature, such as hard disks, primary RAM etc. > These registers cannot be accessed from userspace. Good. The kernel managed hardware. If the memory hierarchy people have userspace now doing stuff behind their back, through some special interface, that makes their world more complicated. This looks like it needs information from the generic memory manager, from the scheduler, and possibly all the way down from the block layer to do the right thing, so it has no business in userspace. Have you seen mm/damon for example? Access to statistics for memory access patterns seems really useful for tuning the behaviour of this hardware. Just my =E2=82=AC0.01. If it does interact with userspace I suppose it should be using control groups, like everything else of this type, see e.g. mm/memcontrol.c, not custom sysfs files. Just an example from one of the patches: + - "* Adjacent Cache Line Prefetcher Disable (R/W)" + corresponds to the "adjacent_cache_line_prefetcher_enable" I might only be on "a little knowledge is dangerous" on the memory manager topics, but I know for sure that they at times adjust the members of structs to fit nicely on cache lines. And now this? It looks really usef= ul for kernel machinery that know very well what needs to go into the cache line next and when. Talk to the people on linux-mm and memory maintainer Andrew Morton on how to do this right, it's a really interesting feature! Also given that people say that the memory hierarchy is an important part in the performance of the Ap= ple M1 (M2) silicon, I expect that machine to have this too? Yours, Linus Walleij