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 66EBBC433EF for ; Wed, 8 Jun 2022 08:06:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E264F6B009D; Wed, 8 Jun 2022 04:06:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD5A16B009E; Wed, 8 Jun 2022 04:06:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C76828D0002; Wed, 8 Jun 2022 04:06:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B6CD06B009D for ; Wed, 8 Jun 2022 04:06:48 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8FBEC20B03 for ; Wed, 8 Jun 2022 08:06:48 +0000 (UTC) X-FDA: 79554337296.07.FFE1876 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf31.hostedemail.com (Postfix) with ESMTP id DE0C020058 for ; Wed, 8 Jun 2022 08:06:47 +0000 (UTC) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 258837w0022441; Wed, 8 Jun 2022 08:04:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=OsOMP2pddvT34VMihhk9HBu9kF1H0WfO+h43RB+Rm3A=; b=dKE4Da97Kx8o+li2nVSML/NLPOeqXir3+wjxeTj7YUf6qwSYYaeiuTWj4P18cjEdJGAV jwmkyUlg3HHeMfYBfDXvMLYa2ydpE5LhXMaUPc4q+jlN5Pcsk+QQkfVWGQ7Q4GF1SJO2 eT8hXjRvUHTxpt06B7k+2hlVeqW80x8NT8G/9FwkPdjnO8oG4wQR8sc3hIZZ6jxyl8Id Z8Z9ZL1Y6T74dtdTXEAQ2dcotL0Nin/QOlpUr+UiAtZaKUYaS/Uj/0B4XmO+up7tCab4 YteeLFasCzSC1OLPz360LjkHMvNAr6c6UmFjSVLmRhx1CAf/lkBoDkAuGupk2H5E4quI tQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gjnyejdpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Jun 2022 08:04:40 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2586S7H6013236; Wed, 8 Jun 2022 08:04:38 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gjnyejdmf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Jun 2022 08:04:38 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2587a5OG017679; Wed, 8 Jun 2022 08:04:35 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3gfy19cue7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Jun 2022 08:04:34 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25884WRj16515396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Jun 2022 08:04:32 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8273C5204F; Wed, 8 Jun 2022 08:04:32 +0000 (GMT) Received: from [9.43.53.124] (unknown [9.43.53.124]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A490E5204E; Wed, 8 Jun 2022 08:04:27 +0000 (GMT) Message-ID: <52b0bb03-a6f6-b68e-49a6-e6d37fe4eaa2@linux.ibm.com> Date: Wed, 8 Jun 2022 13:34:26 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v5 1/9] mm/demotion: Add support for explicit memory tiers Content-Language: en-US To: Ying Huang , 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 References: <20220603134237.131362-1-aneesh.kumar@linux.ibm.com> <20220603134237.131362-2-aneesh.kumar@linux.ibm.com> <92649c9a6e0b6931b34aeaaf22c0a1e874484b7f.camel@linux.intel.com> <71a0734bc918b7a6cf75b0b411b7b6a87f0bda92.camel@intel.com> From: Aneesh Kumar K V In-Reply-To: <71a0734bc918b7a6cf75b0b411b7b6a87f0bda92.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: NFeuMQN_JsKr2J3mVmjNAEo31Rajt9tS X-Proofpoint-ORIG-GUID: Qqr03HE60P0T-PywrolsftA5Kh_B3bd3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-08_02,2022-06-07_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 clxscore=1015 malwarescore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206080035 X-Rspamd-Queue-Id: DE0C020058 X-Stat-Signature: dikpj8qi5jajfjgzwuek9k8gqjnp6u8h X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=dKE4Da97; spf=pass (imf31.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspamd-Server: rspam08 X-HE-Tag: 1654675607-239049 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 6/8/22 11:40 AM, Ying Huang wrote: > 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. As mentioned above current patchset avoid doing that. > And as Tim pointed > out, we need to use it in hot path (for statistics), so some kind of rcu > lock may be good. > Sure when those statistics code get added, we can add the relevant kref and locking details. -aneesh