Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2580923rwb; Fri, 11 Nov 2022 11:21:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf44VGD8nWxLhtKsBAdmmleXk/VO+sC5SMuRzdJVdslLXZxNyZYb5zSBYMj6g+Gz7prbm8uD X-Received: by 2002:a17:906:6d52:b0:7ad:9673:8b73 with SMTP id a18-20020a1709066d5200b007ad96738b73mr3201055ejt.14.1668194499289; Fri, 11 Nov 2022 11:21:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668194499; cv=none; d=google.com; s=arc-20160816; b=ySomGmYVsLuQ/RQkwoSqgpsLkeL7kgx7SJw1/65SM1WYexdEEbEQTKA6aCvXENdU/S XgFyU/E0hBXx9TFkVYqoTKFj41Y91cp6ysXNsHxICNxMExEt6x1SfvheBXz5DC6Pl30q Cr79dCLe165d9gTQmw+La0beK+02J/FqPjRu2z09c30caHiGdr5RmZwy/S+Mt2WYXtr1 LDgQYc6aTDVyctod0Izj1R/oa51prxsG1NaPI/FLj3U+LxjnPM6tDUeslPIe9d/RJJYy 1O0Sn7QAIDwvCbF2HJp8FjtbQ/zW/+lXBHvB5fnK3Qemiclg8bmzkeFQJVO4M1EyYVDo 22vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=j8oM21r0v+ixE5HZSF16LdWe/vK09rOAIJlG3jreBGs=; b=OW0aqozFcE69dGywsoPigQ9tgmvhY1LnSC1HrDKT5jgAqYLrH5LLN9OftTolCJm1NU +0e4LZFhr/z5yn+lGJsv2nDj8zMLBqCpCIfJJgBDENl6I7qBgic/Eln5s5eOTclArIcK m7xYjQVRGB5GkZXt6fuq1o2K1RlLUQI3IuhaKveOLSp6xnBPlU1BmOLohbK2azjz4Ahw AY3OMVz/iHtpU7HPvTfzKxDAhpGbmzC5UrVngBvG1b6R7t2JOc7IRSY0/jFdm4S9VDY8 sSbo+8JtQ8C8ZR59Jvf32ymKVfKoa6r9nka9oTNZIQV8MgandIttn2WOBre4Ky5cXvvz AJHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a056402358400b004637e16cfa4si3493033edc.599.2022.11.11.11.21.17; Fri, 11 Nov 2022 11:21:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233768AbiKKSir (ORCPT + 91 others); Fri, 11 Nov 2022 13:38:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233968AbiKKSi2 (ORCPT ); Fri, 11 Nov 2022 13:38:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5ABF8293C for ; Fri, 11 Nov 2022 10:36:52 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 73F621FB; Fri, 11 Nov 2022 10:36:58 -0800 (PST) Received: from [10.1.197.38] (unknown [10.1.197.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DBDE03F703; Fri, 11 Nov 2022 10:36:50 -0800 (PST) Message-ID: Date: Fri, 11 Nov 2022 18:36:44 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [RFD] resctrl: reassigning a running container's CTRL_MON group Content-Language: en-GB To: Reinette Chatre , Peter Newman Cc: Tony Luck , "Yu, Fenghua" , "Eranian, Stephane" , "linux-kernel@vger.kernel.org" , Thomas Gleixner , Babu Moger , Gaurang Upasani References: <81a7b4f6-fbb5-380e-532d-f2c1fc49b515@intel.com> <76bb4dc9-ab7c-4cb6-d1bf-26436c88c6e2@arm.com> <835d769b-3662-7be5-dcdd-804cb1f3999a@arm.com> <09029c7a-489a-7054-1ab5-01fa879fb42f@intel.com> <8325a442-92c1-4170-1862-3bc891a8d6af@arm.com> From: James Morse In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Reinette, On 09/11/2022 19:12, Reinette Chatre wrote: > On 11/9/2022 9:59 AM, James Morse wrote: >> On 08/11/2022 21:28, Reinette Chatre wrote: >>> On 11/3/2022 10:06 AM, James Morse wrote: >>>> (I've not got to the last message in this part of the thread yes - I'm out of time this >>>> week, back Monday!) >>>> >>>> On 21/10/2022 21:09, Reinette Chatre wrote: >>>>> On 10/19/2022 6:57 AM, James Morse wrote: >>>>>> On 17/10/2022 11:15, Peter Newman wrote: >>>>>>> On Wed, Oct 12, 2022 at 6:55 PM James Morse wrote: >>> >>> ... >>> >>>>>>> If there are a lot more PARTIDs than PMGs, then it would fit well with a >>>>>>> user who never creates child MON groups. In case the number of MON >>>>>>> groups gets ahead of the number of CTRL_MON groups and you've run out of >>>>>>> PMGs, perhaps you would just try to allocate another PARTID and program >>>>>>> the same partitioning configuration before giving up. >>>>>> >>>>>> User-space can choose to do this. >>>>>> If the kernel tries to be clever and do this behind user-space's back, it needs to >>>>>> allocate two monitors for this secretly-two-control-groups, and always sum the counters >>>>>> before reporting them to user-space. >>>> >>>>> If I understand this scenario correctly, the kernel is already doing this. >>>>> As implemented in mon_event_count() the monitor data of a CTRL_MON group is >>>>> the sum of the parent CTRL_MON group and all its child MON groups. >>>> >>>> That is true. MPAM has an additional headache here as it needs to allocate a monitor in >>>> order to read the counters. If there are enough monitors for each CLOSID*RMID to have one, >>>> then MPAM can export the counter files in the same way RDT does. >>>> >>>> While there are systems that have enough monitors, I don't think this is going to be the >>>> norm. To allow systems that don't have a surfeit of monitors to use the counters, I plan >>>> to export the values from resctrl_arch_rmid_read() via perf. (but only for bandwidth counters) >> >>> This sounds related to the way monitoring was done in earlier kernels. This was >>> long before I become involved with this work. Unfortunately I am not familiar with >>> all the history involved that ended in it being removed from the kernel. >> >> Yup, I'm aware there is some history to this. It's not appropriate for the llc_occupancy >> counter as that reports state, instead of events. > Perf counts events while a process is running It's hooked up as an uncore PMU driver and it rejects attempts to attach it to a task. Some useful background is it has to be told which of the existing resctrl control/monitor groups to monitor. On x86 its just returning the the increase in events from the mbm files in resctrl via resctrl_arch_rmid_read(). Unless you're curious [0], the details can come if/when I post it! > so memory bandwidth monitoring may > also be impacted by the caveats Peter mentioned for the upcoming AMD changes: > > https://lore.kernel.org/lkml/CALPaoCidd+WwGTyE3D74LhoL13ce+EvdTmOnyPrQN62j+zZ1fg@mail.gmail.com/ > ("This has the caveats that evictions while one task is running could have > resulted from a previous task on the current CPU, but will be counted > against the new task's software-RMID, ...") If the logic to implement that is hidden entirely behind resctrl_arch_rmid_read(), then there should be no problem. (the values will be noisy, but that is the best that can be done on that platform) Thanks, James [0] Beware, the changes to x86 to make resctrl_arch_rmid_read() irq safe aren't quite right. https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git/commit/?h=mpam/snapshot/v6.0&id=b8ae575bd17e1d56db0f84dc456b964a23d252d6