Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2318860iof; Wed, 8 Jun 2022 02:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnBA51C8goMyU9tZ4hRqnR8DIZWecKgbBjj5HbdlI5XIDst9crnyNPLWlZW/5zSfAqP/xo X-Received: by 2002:a17:902:d64e:b0:163:5074:c130 with SMTP id y14-20020a170902d64e00b001635074c130mr34056037plh.125.1654680001012; Wed, 08 Jun 2022 02:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654680001; cv=none; d=google.com; s=arc-20160816; b=OGOBW+gmyx3CyK+cMaZx98nrGj5FwjL6N68mlT/abqIuKdckmzzVtsfArprmPVeY0N CMvG8EbJpU0ebLmsa0RokXg6TwDls0xOTyDo7lfJByVLVC8GjBtR+ZkCRJ4dtA9h5oF5 fY7/wvW7KRaLEBR+beTHGdtcdpat7bfSmklzoOSjKD2n6KcL12PCm8MB+S7eik2S61hD HoPrsWscQpaCg72y1PbhWge4RiLgv64A3Sb7zCqbTIvMME5tNomaOfKGqyyIoKa5wejb CDddlqb+6JOz7BDxmCbWLpMAC9yax6ERs6hbptW11ghj4ClIIZgqBVlrtfB+UFF+o2Jv 3+bQ== 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:dkim-signature; bh=OsOMP2pddvT34VMihhk9HBu9kF1H0WfO+h43RB+Rm3A=; b=hjioAZVWVOKoJ62lPDrKwu/akbT1oLlC+X0+oPW+AtuglVz88fXsd9/WEiym1aAQuZ GVFWHuodE8BpVCoIeSQeGwdEP1Wl3jojh34D+vT7Eaf/nt4aPuNjr62OG5nNCgmMfVBX U1BtK6ONl7LEthE30/zEMFjmSaLTqcOHFbVkIYl8F0KbM/YqLMpXP6y5DRh/hx6YFD54 gLFqS+N0AIobGDQLYnIC6vUUBZOZJmAcAiOGz/RkuN0x6FwYfF4hI2wmKT9F8dX5VDWZ yGb9PGpsdQaWdyxnqJBMfVB4/RWG0E840Tkw3jfEknnrVcVt9+eif/5Szkllj7Q3x9qJ PePw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=dKE4Da97; 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=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x16-20020a17090a8a9000b001e3495408d6si27972240pjn.123.2022.06.08.02.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 02:20:00 -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=@ibm.com header.s=pp1 header.b=dKE4Da97; 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=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EA4B12AB17; Wed, 8 Jun 2022 01:50:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbiFHIuY (ORCPT + 99 others); Wed, 8 Jun 2022 04:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232384AbiFHItu (ORCPT ); Wed, 8 Jun 2022 04:49:50 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69167CDFD for ; Wed, 8 Jun 2022 01:06:54 -0700 (PDT) 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-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 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