lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 14 Jun 2022 13:50:29 +0530
From:   "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>
To:     Ying Huang <ying.huang@...el.com>, linux-mm@...ck.org,
        akpm@...ux-foundation.org
Cc:     Wei Xu <weixugc@...gle.com>, Greg Thelen <gthelen@...gle.com>,
        Yang Shi <shy828301@...il.com>,
        Davidlohr Bueso <dave@...olabs.net>,
        Tim C Chen <tim.c.chen@...el.com>,
        Brice Goglin <brice.goglin@...il.com>,
        Michal Hocko <mhocko@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Hesham Almatary <hesham.almatary@...wei.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Alistair Popple <apopple@...dia.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Feng Tang <feng.tang@...el.com>,
        Jagdish Gediya <jvgediya@...ux.ibm.com>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        David Rientjes <rientjes@...gle.com>,
        Johannes Weiner <hannes@...xchg.org>
Subject: Re: [PATCH v6 01/13] mm/demotion: Add support for explicit memory
 tiers

Ying Huang <ying.huang@...el.com> writes:

....
> 
>> All those functions are called with memory_tier_lock_held. Infact all 
>> list operations requires that lock held. What details do you suggest we 
>> document? I can add extra comment to the mutex itself? Adding locking 
>> details to all the functions will be duplicating the same details at 
>> multiple places?
>
> memory_tier_lock isn't held to call register_memory_tier() in this
> patch.  That will cause confusion.

will this help to explain this better
modified   mm/memory-tiers.c
@@ -151,6 +151,11 @@ static void insert_memory_tier(struct memory_tier *memtier)
 	struct list_head *ent;
 	struct memory_tier *tmp_memtier;
 
+	if (IS_ENABLED(CONFIG_DEBUG_VM) && !mutex_is_locked(&memory_tier_lock)) {
+		WARN_ON_ONCE(1);
+		return;
+	}
+
 	list_for_each(ent, &memory_tiers) {
 		tmp_memtier = list_entry(ent, struct memory_tier, list);
 		if (tmp_memtier->rank < memtier->rank) {
@@ -811,8 +816,12 @@ static int __init memory_tier_init(void)
 
 	/*
 	 * Register only default memory tier to hide all empty
-	 * memory tier from sysfs.
+	 * memory tier from sysfs. Since this is early during
+	 * boot, we could avoid holding memtory_tier_lock. But
+	 * keep it simple by holding locks. We can add lock
+	 * held debug checks in other functions.
 	 */
+	mutex_lock(&memory_tier_lock);
 	memtier = register_memory_tier(DEFAULT_MEMORY_TIER,
 				       get_rank_from_tier(DEFAULT_MEMORY_TIER));
 
@@ -828,6 +837,7 @@ static int __init memory_tier_init(void)
 		NODE_DATA(node)->memtier = memtier;
 		node_set(node, memtier->nodelist);
 	}
+	mutex_unlock(&memory_tier_lock);
 	migrate_on_reclaim_init();
 
 	return 0;

-aneesh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ