[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120513111328.GD28863@aftab.osrc.amd.com>
Date: Sun, 13 May 2012 13:13:28 +0200
From: Borislav Petkov <bp@...64.org>
To: Alex Shi <alex.shi@...el.com>
Cc: rob@...dley.net, tglx@...utronix.de, mingo@...hat.com,
hpa@...or.com, arnd@...db.de, rostedt@...dmis.org,
fweisbec@...il.com, jeremy@...p.org, gregkh@...uxfoundation.org,
borislav.petkov@....com, riel@...hat.com, luto@....edu,
avi@...hat.com, len.brown@...el.com, dhowells@...hat.com,
fenghua.yu@...el.com, ak@...ux.intel.com, cpw@....com,
steiner@....com, akpm@...ux-foundation.org, penberg@...nel.org,
hughd@...gle.com, rientjes@...gle.com,
kosaki.motohiro@...fujitsu.com, n-horiguchi@...jp.nec.com,
paul.gortmaker@...driver.com, trenn@...e.de, tj@...nel.org,
oleg@...hat.com, axboe@...nel.dk, a.p.zijlstra@...llo.nl,
kamezawa.hiroyu@...fujitsu.com, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 3/7] x86/flush_tlb: try flush_tlb_single one by one in
flush_tlb_range
On Sat, May 12, 2012 at 04:01:20PM +0800, Alex Shi wrote:
> I tried this, found too many goto and label is worse than line breaking. :(
I know exactly what you're saying, I just tried it too. It looks pretty
ugly and unreadable.
Maybe you can carve out the meat of the function into another helper,
see below.
Dunno, it kinda looks ok if I haven't fat-fingered all the return paths
and it could use a bunch of comments and maybe even better naming to
explain what happens:
---
static bool __flush_tlb_range(unsigned int cpu, struct mm_struct *mm,
unsigned long start, unsigned long end,
unsigned long vmflag)
{
unsigned long addr;
unsigned long act_entries, tlb_entries = 0;
if (end == TLB_FLUSH_ALL || tlb_flushall_factor == (u16)TLB_FLUSH_ALL)
goto flush_out;
tlb_entries = (vmflag & VM_EXEC ? tlb_lli_4k[ENTRIES]
: tlb_lld_4k[ENTRIES]);
act_entries = min(mm->total_vm, tlb_entries);
if ((end - start) >> PAGE_SHIFT > act_entries >> tlb_flushall_factor)
goto flush_out;
if (has_large_page(mm, start, end))
goto flush_out;
for (addr = start; addr <= end; addr += PAGE_SIZE)
__flush_tlb_single(addr);
if (cpumask_any_but(mm_cpumask(mm), cpu) < nr_cpu_ids)
flush_tlb_others(mm_cpumask(mm), mm, start, end);
return true;
flush_out:
local_flush_tlb();
return false;
}
void _flush_tlb_range(struct mm_struct *mm, unsigned long start,
unsigned long end, unsigned long vmflag)
{
unsigned int cpu = smp_processor_id();
preempt_disable();
if (current->active_mm != mm)
goto flush_all;
if (!current->mm) {
leave_mm(cpu);
goto flush_all;
}
if (__flush_tlb_range(cpu, mm, start, end, vmflag))
goto out;
flush_all:
if (cpumask_any_but(mm_cpumask(mm), cpu) < nr_cpu_ids)
flush_tlb_others(mm_cpumask(mm), mm, 0UL, TLB_FLUSH_ALL);
out:
preempt_enable();
}
--
Oh well, enough games :-).
--
Regards/Gruss,
Boris.
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
--
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