Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3990381rwo; Mon, 24 Jul 2023 21:46:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgvVie/x5MBOmCGpuzWKHen3wFiq7rMuX+rMtwdzhJVQV0yQPhqPRkFf+zX8Hn29LuoYJg X-Received: by 2002:a05:6a20:8f06:b0:f0:50c4:4c43 with SMTP id b6-20020a056a208f0600b000f050c44c43mr2000828pzk.5.1690260400187; Mon, 24 Jul 2023 21:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690260400; cv=none; d=google.com; s=arc-20160816; b=FoAzVpVGeXykXkPgrWOOMF9YLnDbOHL1+bbYc32z5yw29bc/1DrCsv21kxdkC+IDzS EX8m0E5hsy3/Qn/cnmH4KRBftUhvpA/ea2k0DGZkj4GInEJYFg9fvlw0OlsL33xHRBnE kyGRbxOMG3LFCTDaLISiUylGaEJUv4IIQEmYuBkjp3f2KYPfNB2LPngyzRDTCu8U/bG5 hqFpBAu3R6eHROb++bJ5RvBNuMJdTVtNBnU6Q2NGhzEuC/hziAHU+jtcS8tbHffbUhPO PVUwHYG8lK6Ujx4JIgx/48+maAkoZ8QHqhU8vpA/Q5tCKeUwEKaWBqvQepIZ4e8juIk6 qutA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=qIFslydowtZ7legH7zTLI6WGlD99CxiTe/N/B7CmlmQ=; fh=8sTu+vB2ZLrI8ZqcZj9tRY15EEtaF3bUperoUDTsu3Y=; b=ODFXuBa9XyiCMtyzZAIYgZNgX0o4szyXCHKD2ywpmOCJYVKH+r+Ea7Jt/+Q6XrfK/g Jqt06z98sO0AD7MURn0quZ1AvmRDmiDjehxrzcqpWxyKNLmewxJfAQ+0h0dVAhApZUF9 LhrUqJAx5kokxnILa19qs65gvd0LOz6OSrwEqmFqsXtAgSge/DtvbdcyFbkS8pRci2c9 0AgMazV6haiwSYAHeF1BnviuYn2S6GFJWt2Q18mm+F6rUw59g9LA1L9C0CwLtohrnLql XTDluloYardjEtnGOUsCWdnLhzPnU6BHA9JG5y3teh5SlZCU9ROAzGHnUCSXLq5fsgxf jFJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FE+Gm8qK; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056a000b8d00b006535a72d26csi11077037pfj.152.2023.07.24.21.46.28; Mon, 24 Jul 2023 21:46:40 -0700 (PDT) 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=@intel.com header.s=Intel header.b=FE+Gm8qK; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbjGYDQ0 (ORCPT + 99 others); Mon, 24 Jul 2023 23:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbjGYDQZ (ORCPT ); Mon, 24 Jul 2023 23:16:25 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C8610EF; Mon, 24 Jul 2023 20:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690254983; x=1721790983; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=eXqEf3qlKPxbWMmz2TfO/Y35RDERdVQkGU4AZ8/UTeY=; b=FE+Gm8qKZASj4+owYumKxdStPDTvs+XYzkBpnGU2gIRBUDhT0HU4xfde bJvKgeRbdKyUdDMPDBIVIcsLLwTHesHWjpqKK0RB/8xliKMTWRp33Q1bp 18CZ5X9DQ+MJ2yiqSWH8ep3tfUj9D/EQCShYbtScGi25APWZUPiPfh+31 MQuFLrtL0z+rrMJdtoECfGPmGw1qfWb2wXroop+R0T3gBlvm9pyP8jkvE MJXwi0LwFk+mckCKG93T9LyVyhoBkuos8bu1+nwWoKc7NjLPVhzpvS8qs vRywYcLKOhQkTK1VEcaUwSXbVcqrQOZFhGlG1RJ9No1L6y9R7crFqhMbJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="347211935" X-IronPort-AV: E=Sophos;i="6.01,229,1684825200"; d="scan'208";a="347211935" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 20:16:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10781"; a="729174386" X-IronPort-AV: E=Sophos;i="6.01,229,1684825200"; d="scan'208";a="729174386" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 20:16:19 -0700 From: "Huang, Ying" To: Alistair Popple Cc: Andrew Morton , , , , , , "Aneesh Kumar K . V" , Wei Xu , Dan Williams , Dave Hansen , "Davidlohr Bueso" , Johannes Weiner , "Jonathan Cameron" , Michal Hocko , Yang Shi , Rafael J Wysocki , Dave Jiang Subject: Re: [PATCH RESEND 1/4] memory tiering: add abstract distance calculation algorithms management References: <20230721012932.190742-1-ying.huang@intel.com> <20230721012932.190742-2-ying.huang@intel.com> <87r0owzqdc.fsf@nvdebian.thelocal> Date: Tue, 25 Jul 2023 11:14:38 +0800 In-Reply-To: <87r0owzqdc.fsf@nvdebian.thelocal> (Alistair Popple's message of "Tue, 25 Jul 2023 12:13:49 +1000") Message-ID: <87r0owy95t.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii 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_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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, Alistair, Thanks a lot for comments! Alistair Popple writes: > Huang Ying writes: > >> The abstract distance may be calculated by various drivers, such as >> ACPI HMAT, CXL CDAT, etc. While it may be used by various code which >> hot-add memory node, such as dax/kmem etc. To decouple the algorithm >> users and the providers, the abstract distance calculation algorithms >> management mechanism is implemented in this patch. It provides >> interface for the providers to register the implementation, and >> interface for the users. > > I wonder if we need this level of decoupling though? It seems to me like > it would be simpler and better for drivers to calculate the abstract > distance directly themselves by calling the desired algorithm (eg. ACPI > HMAT) and pass this when creating the nodes rather than having a > notifier chain. Per my understanding, ACPI HMAT and memory device drivers (such as dax/kmem) may belong to different subsystems (ACPI vs. dax). It's not good to call functions across subsystems directly. So, I think it's better to use a general subsystem: memory-tier.c to decouple them. If it turns out that a notifier chain is unnecessary, we can use some function pointers instead. > At the moment it seems we've only identified two possible algorithms > (ACPI HMAT and CXL CDAT) and I don't think it would make sense for one > of those to fallback to the other based on priority, so why not just > have drivers call the correct algorithm directly? For example, we have a system with PMEM (persistent memory, Optane DCPMM, or AEP, or something else) in DIMM slots and CXL.mem connected via CXL link to a remote memory pool. We will need ACPI HMAT for PMEM and CXL CDAT for CXL.mem. One way is to make dax/kmem identify the types of the device and call corresponding algorithms. The other way (suggested by this series) is to make dax/kmem call a notifier chain, then CXL CDAT or ACPI HMAT can identify the type of device and calculate the distance if the type is correct for them. I don't think that it's good to make dax/kem to know every possible types of memory devices. >> Multiple algorithm implementations can cooperate via calculating >> abstract distance for different memory nodes. The preference of >> algorithm implementations can be specified via >> priority (notifier_block.priority). > > How/what decides the priority though? That seems like something better > decided by a device driver than the algorithm driver IMHO. Do we need the memory device driver specific priority? Or we just share a common priority? For example, the priority of CXL CDAT is always higher than that of ACPI HMAT? Or architecture specific? And, I don't think that we are forced to use the general notifier chain interface in all memory device drivers. If the memory device driver has better understanding of the memory device, it can use other way to determine abstract distance. For example, a CXL memory device driver can identify abstract distance by itself. While other memory device drivers can use the general notifier chain interface at the same time. -- Best Regards, Huang, Ying