Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2290933iof; Wed, 8 Jun 2022 01:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6T8coSmSmTzZBEKqyojlZmMP6+rv8OoV8kXeRgDPhHfZ1KqK+04VOoBXNyjZEDLilhKEb X-Received: by 2002:a17:902:c951:b0:163:efad:406d with SMTP id i17-20020a170902c95100b00163efad406dmr33095834pla.55.1654677330482; Wed, 08 Jun 2022 01:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654677330; cv=none; d=google.com; s=arc-20160816; b=qwzl9VuWz/5jg04Tyq4FDwCuc6wfwdOrH4kyKoKQ47I1zqklS1zLq/K0ufgUQbrDq5 juWp/65AIYJ47j3/8SXoX9RQfbIIxuDcvKUXicuzqmudsmwdhMzktC1a66Sk0NlppcD1 9SLS+sbkIY2uM4pAC8lhcUvnp844N8mc6kuqvdGux7K1uxvhxlF7qYJiIQlJ5kgMw9Vm zl372LEe+P6bZJN++yWuJudMXxGvYzkT+sBSw1JHZpWwbuNPUwFtH9q1eb92ELnfGgH2 1uck7gVUHKNL/xHbZWJMcvOkUpwo2UoYge/4x1qnpMrsHj1kKOF47NUCoHM0Q4R7Yq7Q 3JxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=kj+FtkEs0Al0BNcZ3Yxt/9h1RjyNcrhJ3j65yla62MY=; b=CXzJsz32wSWqfIGv6iHuxybS642SiHf6H1byzuQNNYnjAls6NlueTwoIziGY9OvHfa yzh44i1uHBtkxwgIxHkJQ3nIqOZTmq2fILX63XnO+ObbD2OWDYOeMPxZ8qf1mOXmq2t+ fFDEbyTWObThdFX/FBPHATVdVppgH/XU7CRPHNomRZFtZUCJ9SzcqZg4ZqgdDniSYnqn 3Mf5QqeWWn4p9mfe32YJMN4lMlWVQC/WxXUaZANEaY2KGevU3RmPsKQQ6RnafGOnV32v a4qISN9/YDg3D8u6ddaWcT7bWR2kjxFX77fmUKsRSZSDVN4g2EfYfLyGh6PbwjpBPXw4 BBZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nI4UK6g2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ja20-20020a170902efd400b0016153e8acc9si24250880plb.607.2022.06.08.01.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:35:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nI4UK6g2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D2B8C236847; Wed, 8 Jun 2022 01:01:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235367AbiFHHJo (ORCPT + 99 others); Wed, 8 Jun 2022 03:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354397AbiFHGTe (ORCPT ); Wed, 8 Jun 2022 02:19:34 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6F9ED714 for ; Tue, 7 Jun 2022 23:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654668609; x=1686204609; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=wSpGqlJOs7netwFupcWWwUUiv8vP2SDhvcyzrkviMpI=; b=nI4UK6g2LehhIK5IUPM/BzT7jeCn5Jbk694ihEDY5HnkcQySy1P+8vQZ j3ovHrklHiz/ghi5pI4M7qOr3k4It5DPp8IpYD++PbOr+xSz9a1UU999a tZYCjISv5qbQx/ST12sb36Cxs/NxJFjz/DrqwyngaSV9qVCGy/mcjlu1V aIP17EQxL7JKPzVa0Xghce/Vmapu46S4p99G4crLbR3yFGzKpvGZF9L9p jYAcTuOVn2zJSjbFlohFDbV0VRpPmKtqVe5xdNYHm1oZOhXufEUI8GxjZ hXnv4hFtlRZegEadULUAeSGPVISmRbxKH4ERgOIAvBGY3fzJbIt9RPqeq g==; X-IronPort-AV: E=McAfee;i="6400,9594,10371"; a="274326300" X-IronPort-AV: E=Sophos;i="5.91,285,1647327600"; d="scan'208";a="274326300" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 23:10:09 -0700 X-IronPort-AV: E=Sophos;i="5.91,285,1647327600"; d="scan'208";a="826761637" Received: from xding11-mobl.ccr.corp.intel.com ([10.254.214.239]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 23:10:04 -0700 Message-ID: <71a0734bc918b7a6cf75b0b411b7b6a87f0bda92.camel@intel.com> Subject: Re: [PATCH v5 1/9] mm/demotion: Add support for explicit memory tiers From: Ying Huang To: Aneesh Kumar K V , Tim Chen , linux-mm@kvack.org, akpm@linux-foundation.org Cc: Wei Xu , Greg Thelen , Yang Shi , Davidlohr Bueso , Tim C Chen , Brice Goglin , Michal Hocko , Linux Kernel Mailing List , Hesham Almatary , Dave Hansen , Jonathan Cameron , Alistair Popple , Dan Williams , Feng Tang , Jagdish Gediya , Baolin Wang , David Rientjes Date: Wed, 08 Jun 2022 14:10:02 +0800 In-Reply-To: References: <20220603134237.131362-1-aneesh.kumar@linux.ibm.com> <20220603134237.131362-2-aneesh.kumar@linux.ibm.com> <92649c9a6e0b6931b34aeaaf22c0a1e874484b7f.camel@linux.intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Wed, 2022-06-08 at 10:07 +0530, Aneesh Kumar K V wrote: > On 6/8/22 12:13 AM, Tim Chen wrote: > ... > > > > > > > + > > > +static void memory_tier_device_release(struct device *dev) > > > +{ > > > + struct memory_tier *tier = to_memory_tier(dev); > > > + > > > > Do we need some ref counts on memory_tier? > > If there is another device still using the same memtier, > > free below could cause problem. > > > > > + kfree(tier); > > > +} > > > + > > > > > ... > > The lifecycle of the memory_tier struct is tied to the sysfs device life > time. ie, memory_tier_device_relese get called only after the last > reference on that sysfs dev object is released. Hence we can be sure > there is no userspace that is keeping one of the memtier related sysfs > file open. > > W.r.t other memory device sharing the same memtier, we unregister the > sysfs device only when the memory tier nodelist is empty. That is no > memory device is present in this memory tier. memory_tier isn't only used by user space. It is used inside kernel too. If some kernel code get a pointer to struct memory_tier, we need to guarantee the pointer will not be freed under us. And as Tim pointed out, we need to use it in hot path (for statistics), so some kind of rcu lock may be good. Best Regards, Huang, Ying