Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp439260rdb; Mon, 18 Sep 2023 22:59:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGU9uLREp5SPbSeay7NESW4C1vr1LdKqGz9ECg7CmQf1zmQ6LAmB7LJ5CDtNTk1I6YUUZYo X-Received: by 2002:a17:902:ced1:b0:1c1:f27e:a55a with SMTP id d17-20020a170902ced100b001c1f27ea55amr11594204plg.46.1695103141171; Mon, 18 Sep 2023 22:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695103141; cv=none; d=google.com; s=arc-20160816; b=q2LpH2cT5i2c+96QYhnnG/wOHbYgX0MgLw85sLlyZCgyoNjLdsCIW3PPsTpNT/em6t K8wUFvOxFtQ6fI5TDjKQFJuRa9R4mGmnk41WDTDTAdVxfxetjoa0ifwqZzFO553xWH3U qKzcWhtTlS6PhhtCP9GviVDp2jgteEkCP/uPgBL2U6PfYJWvjGJoQ9YcypB9WJ40sqnl 2bHHUhZVNM48Q8bbxdRwMTZSe5P17t+TzP2MZOfS4FXq1uDzpvzJttkhL2XMShrc5l3U sisK4XkQ3Bjqi+2d1XRiCSE8ZOEZwfLBogP7MawqAtW7t7gsfUrvZLXyDVjwObIYZ0UG 0yIg== 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=zAXNnjHQ3dO7Ak24DeY9zXAdYe19wsgH8Qj7L850Bo8=; fh=5Y9yv03bgp065DML2h0GfCVkXJ4DKFWvgljAwBr/4r8=; b=dG7aKrLYU5+OUseVI0QN9WoQl75F2Tiey6uCwPubNBaKcJHF6BOCZ9/IezOR+5jmpB 0y4uoiwUzJBJa8UA8zHyDT1vFStc5l+BA4uHbqnmFAjvI9xgmCMFbM7akZ3uSc40tbiw U0+2a2vzdQUnpbT9jVOMUA8Mv5i5vf5ZRAuOatmfNMRVJEAGgWVw6VoYCCxEnTFOZU9t QE5iXoWh47zHgUPFNle+TjFmC1z9j0m+cMmhs9Al218eRn+0/ydrqbi6axTXOFMu+FaE CDxqw/OBYq4mO+tZcSbSwlnZe98Ql0zVmj0yiNPpQGIfYr2KQxczGO3WnTPLtPCn5r2X c2xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ndx9wht2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id i13-20020a17090332cd00b001c38666f77dsi9729196plr.596.2023.09.18.22.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 22:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ndx9wht2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7B28E8201788; Mon, 18 Sep 2023 22:58:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbjISF6x (ORCPT + 99 others); Tue, 19 Sep 2023 01:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbjISF6w (ORCPT ); Tue, 19 Sep 2023 01:58:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8548FC for ; Mon, 18 Sep 2023 22:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695103126; x=1726639126; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=KAmPPpxW9liLl58sEZSznsJl5MqLZx/QqZBmppsxNqU=; b=Ndx9wht2TEAgle9shkECPzjI5pr6rlcg26/awyAfwmfjy0IpHBLbyEkf z9we0Gl+9sYPE46P09pSFBaL7KPxocErPFPXXMDQJY/4UfyD+3dP0peI9 ZQvr51JiOiphFGgqbOpjpN24l9AFFbOn7aCT2wU0BMkZVTBzUN6EDK3dO /bbLwIc/fv0ni0+XqANR+IvbBkeKt7HZ65OlCKBH0psjfheP2Saje2xxq aRkueChJpueOXUwJyIXYDybvQj/yFeIFAkiXAXbC6INRblxLFqUwJaAai gQEOHyopVGyOORb5KNgWY7JzN9w2qwoNjXlfFtNQ9lC39DcpShaYPd1UF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="379761900" X-IronPort-AV: E=Sophos;i="6.02,158,1688454000"; d="scan'208";a="379761900" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 22:58:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="919737430" X-IronPort-AV: E=Sophos;i="6.02,158,1688454000"; d="scan'208";a="919737430" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 22:58:41 -0700 From: "Huang, Ying" To: Alistair Popple Cc: Andrew Morton , , , Bharata B Rao , "Aneesh Kumar K . V" , Wei Xu , "Dan Williams" , Dave Hansen , Davidlohr Bueso , Johannes Weiner , Jonathan Cameron , Michal Hocko , Yang Shi , Dave Jiang , Rafael J Wysocki Subject: Re: [PATCH -V3 4/4] dax, kmem: calculate abstract distance with general interface References: <20230912082101.342002-1-ying.huang@intel.com> <20230912082101.342002-5-ying.huang@intel.com> <87y1h24tft.fsf@nvdebian.thelocal> Date: Tue, 19 Sep 2023 13:56:33 +0800 In-Reply-To: <87y1h24tft.fsf@nvdebian.thelocal> (Alistair Popple's message of "Tue, 19 Sep 2023 15:31:29 +1000") Message-ID: <8734zayacu.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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 22:58:57 -0700 (PDT) Alistair Popple writes: > Huang Ying writes: > >> diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c >> index fa1a8b418f9a..ca68ef17554b 100644 >> --- a/mm/memory-tiers.c >> +++ b/mm/memory-tiers.c >> @@ -586,7 +586,7 @@ EXPORT_SYMBOL_GPL(init_node_memory_type); >> void clear_node_memory_type(int node, struct memory_dev_type *memtype) >> { >> mutex_lock(&memory_tier_lock); >> - if (node_memory_types[node].memtype == memtype) >> + if (node_memory_types[node].memtype == memtype || !memtype) >> node_memory_types[node].map_count--; >> >> /* >> * If we umapped all the attached devices to this node, > > This implies it's possible memtype == NULL. Yet we have this: > > * clear the node memory type. > */ > if (!node_memory_types[node].map_count) { > node_memory_types[node].memtype = NULL; > put_memory_type(memtype); > } > > It's not safe to call put_memory_type(NULL), so what condition guarantees > map_count > 1 when called with memtype == NULL? Thanks. Nothing guarantees that. Thanks for pointing this out. I will revise the code to put_memory_type(node_memory_types[node].memtype) firstly. -- Best Regards, Huang, Ying