Re: [PATCH v9 8/10] x86, mm: Add set_memory_wt() for WT

From: Toshi Kani
Date: Fri May 22 2015 - 11:49:51 EST


On Fri, 2015-05-22 at 09:48 +0200, Thomas Gleixner wrote:
> On Wed, 13 May 2015, Toshi Kani wrote:
> > +int set_memory_wt(unsigned long addr, int numpages)
> > +{
> > + int ret;
> > +
> > + if (!pat_enabled)
> > + return set_memory_uc(addr, numpages);
> > +
> > + ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE,
> > + _PAGE_CACHE_MODE_WT, NULL);
> > + if (ret)
> > + goto out_err;
> > +
> > + ret = _set_memory_wt(addr, numpages);
> > + if (ret)
> > + goto out_free;
> > +
> > + return 0;
> > +
> > +out_free:
> > + free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);
> > +out_err:
> > + return ret;
>
>
> This goto zoo is horrible to read. What's wrong with a straight forward:
>
> + if (!pat_enabled)
> + return set_memory_uc(addr, numpages);
> +
> + ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE,
> + _PAGE_CACHE_MODE_WT, NULL);
> + if (ret)
> + return ret;
> +
> + ret = _set_memory_wt(addr, numpages);
> + if (ret)
> + free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);
> + return ret;

Agreed. I will change set_memory_wc() as well, which is the base of
this function.

Thanks,
-Toshi


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