Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp794932rwb; Fri, 18 Nov 2022 08:19:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf6YJH4lYp/EoTkkS71Df9ONzwGnnUOcFQ3ZYgsb8+JHZbiOJontlWnSroc4ANYYKU/vY6Rm X-Received: by 2002:a17:903:456:b0:17f:5810:e9e3 with SMTP id iw22-20020a170903045600b0017f5810e9e3mr336115plb.11.1668788362453; Fri, 18 Nov 2022 08:19:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668788362; cv=none; d=google.com; s=arc-20160816; b=Gf0gKtjnYuYxiQ7gYHxn2ceKEiutr0mjGrO7Gxs4XRiJLl1uvyq8tFYpEMmhlHZGJ1 tlAB84UXtcnaRUdZyZpz3CMXlaka8kssleAfNF/rQ+ik/+QlcIBZ3ulJ1FCPBTaiKDBP ZilJyzZOofd/LuoUtr3LsReg2wpn2BKTOKX1vRZ2fPaFfYNrZLEnU28jAhUeWb30PJG3 qJbL7DV70mzftXB5TEYaYsmKCp6HOHEOZcZcf/JTH3wPPX9LW6jt+VsGWI8qBhHfn7Bv jiMWkQjBrBDRVrGMIWpX/LdOwEbaqmG7rkET8QSrYeRklN+uHJQCH6P0cvG1mFwPzytX IfHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=f0l961mOiSvfsHXNC9b/4yL94fMPoEXmeS8Dl+sxaT8=; b=sci/JSFAdMgHyI8VZhiGTQBI1+rJU1PoyIFt8BucVK4ThrCnpQhx35yjyQtUTnSux6 /Vu6t7mbvV7l8bXoizJ/OjhHnhq+8FqumB7NSey3nAb2fJzJZO30GDYePdkFSioFmCfh 0Iubg9CVkvVBSWlqewhjREvxpuscLDCFdsnH9/T96eWvqQ8V+jmZdE9Opuf3+GtC0UzW XuvFKJpKEYKZ5VA3lG0V9rhyOL1bgkOgPy0Ui4B2vgybRb0VFhYwQ07xC26T/t2lXgoz Ii+XutpoUk1BRAZUFBYFZ+jJJ7f8PelBZurK4N0xt5oALJaDghutIPzRcLNI5wX/h3wt 2wJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cDS+gEqg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z190-20020a6265c7000000b00563352f734asi3707320pfb.69.2022.11.18.08.19.10; Fri, 18 Nov 2022 08:19:22 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cDS+gEqg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235043AbiKRPwv (ORCPT + 91 others); Fri, 18 Nov 2022 10:52:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242437AbiKRPux (ORCPT ); Fri, 18 Nov 2022 10:50:53 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44CB88B131 for ; Fri, 18 Nov 2022 07:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668786594; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f0l961mOiSvfsHXNC9b/4yL94fMPoEXmeS8Dl+sxaT8=; b=cDS+gEqgTxQyXDDO4CZ+fmuJpaM/7WR1lANsy0H2+N58OlaJmwZBBQGRzvoc8hUIKvwe/1 EeapbLrIp5tp6sv09en8vdC3TcwEOVOm1E1G4X/Y4BwSjdkXMIe6Jq5zMrXtohRWwn8wfN M3sY02iXQVnBOVvOcjxbC01CQ70dn2Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-102-trLBXlhbN5-D4oMcLJIDlw-1; Fri, 18 Nov 2022 10:49:52 -0500 X-MC-Unique: trLBXlhbN5-D4oMcLJIDlw-1 Received: by mail-wm1-f70.google.com with SMTP id o5-20020a05600c510500b003cfca1a327fso2425901wms.8 for ; Fri, 18 Nov 2022 07:49:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f0l961mOiSvfsHXNC9b/4yL94fMPoEXmeS8Dl+sxaT8=; b=xo3aU5BM7qY2v5DftPOmg2M8qJbU+hdBAp2EzGtMc4dzBuxrUtHzLgAhewBGABbtKR 3yvDM6hxKxLxzvH9f0/I3b8s+ZIVefkvmciQiQJfxN25Bo50OAY+WZWRj+NO2dzYIEES v+O5AJ/NDrFldswMbi1QOzEwQQtY0pyqLZam4aVh7J2L+op725EJroIw5fNTQkFtif2q q7pq0o2KXNZZjVkbHKLXsys8JAaaGNufeFtwSoG+Jf9MsXYmaUzLHNm3IgqjLsVQ7Iak agVyvZ1h8dnjo9og2TxI7d66X8QTCFmkvB36WK6iewxQpxUrdbYflwoxm3X84JoiSMcR B3Lw== X-Gm-Message-State: ANoB5pmUkx1Va3TK5HDaPe9cEmQAn9trJ1VEMLsMbPXKX3DFBgWtQ982 TJHkSm8UyLMw9i2rzhIvP5cK7iFc5rGpEEwRbcb91OjQTeMIwO6NHaArBzq0Ey7SPw+VLe20NOX ASri+nGhfERIOYAy9Tu+8oVkm X-Received: by 2002:a5d:6746:0:b0:22e:39c9:a4a6 with SMTP id l6-20020a5d6746000000b0022e39c9a4a6mr4764198wrw.170.1668786591680; Fri, 18 Nov 2022 07:49:51 -0800 (PST) X-Received: by 2002:a5d:6746:0:b0:22e:39c9:a4a6 with SMTP id l6-20020a5d6746000000b0022e39c9a4a6mr4764178wrw.170.1668786591405; Fri, 18 Nov 2022 07:49:51 -0800 (PST) Received: from vschneid.remote.csb ([154.57.232.159]) by smtp.gmail.com with ESMTPSA id f16-20020a5d50d0000000b00235da296623sm3807096wrt.31.2022.11.18.07.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 07:49:50 -0800 (PST) From: Valentin Schneider To: James Morse , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, peternewman@google.com Subject: Re: [PATCH 07/18] x86/resctrl: Move CLOSID/RMID matching and setting to use helpers In-Reply-To: <20221021131204.5581-8-james.morse@arm.com> References: <20221021131204.5581-1-james.morse@arm.com> <20221021131204.5581-8-james.morse@arm.com> Date: Fri, 18 Nov 2022 15:49:47 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 On 21/10/22 13:11, James Morse wrote: > When switching tasks, the CLOSID and RMID that the new task should > use are stored in struct task_struct. For x86 the CLOSID known by resctrl, > the value in task_struct, and the value written to the CPU register are > all the same thing. > > MPAM's CPU interface has two different PARTID's one for data accesses > the other for instruction fetch. Storing resctrl's CLOSID value in > struct task_struct implies the arch code knows whether resctrl is using > CDP. > > Move the matching and setting of the struct task_struct properties > to use helpers. This allows arm64 to store the hardware format of > the register, instead of having to convert it each time. > > __rdtgroup_move_task()s use of READ_ONCE()/WRITE_ONCE() ensures torn > values aren't seen as another CPU may schedule the task being moved > while the value is being changed. MPAM has an additional corner-case > here as the PMG bits extend the PARTID space. If the scheduler sees a > new-CLOSID but old-RMID, the task will dirty an RMID that the limbo code > is not watching causing an inaccurate count. x86's RMID are independent > values, so the limbo code will still be watching the old-RMID in this > circumstance. > To avoid this, arm64 needs both the CLOSID/RMID WRITE_ONCE()d together. > Both values must be provided together. > I think I remember something about this... Is that about having them union'd and read/written as one? (just for my own curiosity) > Because MPAM's RMID values are not unique, the CLOSID must be provided > when matching the RMID. > > CC: Valentin Schneider > Signed-off-by: James Morse Reviewed-by: Valentin Schneider