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]
Message-ID: <4F4C74D1.3040909@openvz.org>
Date:	Tue, 28 Feb 2012 10:31:45 +0400
From:	Konstantin Khlebnikov <khlebnikov@...nvz.org>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
CC:	Hugh Dickins <hughd@...gle.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	Johannes Weiner <hannes@...xchg.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Andi Kleen <andi@...stfloor.org>
Subject: Re: [PATCH v3 16/21] mm: handle lruvec relocks in compaction

KAMEZAWA Hiroyuki wrote:
> On Thu, 23 Feb 2012 17:52:56 +0400
> Konstantin Khlebnikov<khlebnikov@...nvz.org>  wrote:
>
>> Prepare for lru_lock splitting in memory compaction code.
>>
>> * disable irqs in acct_isolated() for __mod_zone_page_state(),
>>    lru_lock isn't required there.
>>
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@...nvz.org>
>> ---
>>   mm/compaction.c |   30 ++++++++++++++++--------------
>>   1 files changed, 16 insertions(+), 14 deletions(-)
>>
>> diff --git a/mm/compaction.c b/mm/compaction.c
>> index a976b28..54340e4 100644
>> --- a/mm/compaction.c
>> +++ b/mm/compaction.c
>> @@ -224,8 +224,10 @@ static void acct_isolated(struct zone *zone, struct compact_control *cc)
>>   	list_for_each_entry(page,&cc->migratepages, lru)
>>   		count[!!page_is_file_cache(page)]++;
>>
>> +	local_irq_disable();
>>   	__mod_zone_page_state(zone, NR_ISOLATED_ANON, count[0]);
>>   	__mod_zone_page_state(zone, NR_ISOLATED_FILE, count[1]);
>> +	local_irq_enable();
>
> Why we need to disable Irq here ??

__mod_zone_page_state() want this to protect per-cpu counters, maybe preempt_disable() is enough.

>
>
>
>>   }
>>
>>   /* Similar to reclaim, but different enough that they don't share logic */
>> @@ -262,7 +264,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
>>   	unsigned long nr_scanned = 0, nr_isolated = 0;
>>   	struct list_head *migratelist =&cc->migratepages;
>>   	isolate_mode_t mode = ISOLATE_ACTIVE|ISOLATE_INACTIVE;
>> -	struct lruvec *lruvec;
>> +	struct lruvec *lruvec = NULL;
>>
>>   	/* Do not scan outside zone boundaries */
>>   	low_pfn = max(cc->migrate_pfn, zone->zone_start_pfn);
>> @@ -294,25 +296,24 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
>>
>>   	/* Time to isolate some pages for migration */
>>   	cond_resched();
>> -	spin_lock_irq(&zone->lru_lock);
>>   	for (; low_pfn<  end_pfn; low_pfn++) {
>>   		struct page *page;
>> -		bool locked = true;
>>
>>   		/* give a chance to irqs before checking need_resched() */
>>   		if (!((low_pfn+1) % SWAP_CLUSTER_MAX)) {
>> -			spin_unlock_irq(&zone->lru_lock);
>> -			locked = false;
>> +			if (lruvec)
>> +				unlock_lruvec_irq(lruvec);
>> +			lruvec = NULL;
>>   		}
>> -		if (need_resched() || spin_is_contended(&zone->lru_lock)) {
>> -			if (locked)
>> -				spin_unlock_irq(&zone->lru_lock);
>> +		if (need_resched() ||
>> +		    (lruvec&&  spin_is_contended(&zone->lru_lock))) {
>> +			if (lruvec)
>> +				unlock_lruvec_irq(lruvec);
>> +			lruvec = NULL;
>>   			cond_resched();
>> -			spin_lock_irq(&zone->lru_lock);
>>   			if (fatal_signal_pending(current))
>>   				break;
>> -		} else if (!locked)
>> -			spin_lock_irq(&zone->lru_lock);
>> +		}
>>
>>   		/*
>>   		 * migrate_pfn does not necessarily start aligned to a
>> @@ -359,7 +360,7 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
>>   			continue;
>>   		}
>>
>> -		if (!PageLRU(page))
>> +		if (!__lock_page_lruvec_irq(&lruvec, page))
>>   			continue;
>
> Could you add more comments onto __lock_page_lruvec_irq() ?

Actually there is a very unlikely race with page free-realloc,
(which is fixed in Hugh's patchset, and surprisingly fixed in my old memory controller)
thus this part will be redesigned.

>
> Thanks,
> -Kame
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ