|
Message-ID: <20181026094105.GE3159@worktop.c.hoisthospitality.com> Date: Fri, 26 Oct 2018 11:41:05 +0200 From: Peter Zijlstra <peterz@...radead.org> To: Igor Stoppa <igor.stoppa@...il.com> Cc: Mimi Zohar <zohar@...ux.vnet.ibm.com>, Kees Cook <keescook@...omium.org>, Matthew Wilcox <willy@...radead.org>, Dave Chinner <david@...morbit.com>, James Morris <jmorris@...ei.org>, Michal Hocko <mhocko@...nel.org>, kernel-hardening@...ts.openwall.com, linux-integrity@...r.kernel.org, linux-security-module@...r.kernel.org, igor.stoppa@...wei.com, Dave Hansen <dave.hansen@...ux.intel.com>, Jonathan Corbet <corbet@....net>, Laura Abbott <labbott@...hat.com>, Vlastimil Babka <vbabka@...e.cz>, "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>, Andrew Morton <akpm@...ux-foundation.org>, Pavel Tatashin <pasha.tatashin@...cle.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org Subject: Re: [PATCH 02/17] prmem: write rare for static allocation On Wed, Oct 24, 2018 at 12:34:49AM +0300, Igor Stoppa wrote: > +static __always_inline That's far too large for inline. > +bool wr_memset(const void *dst, const int c, size_t n_bytes) > +{ > + size_t size; > + unsigned long flags; > + uintptr_t d = (uintptr_t)dst; > + > + if (WARN(!__is_wr_after_init(dst, n_bytes), WR_ERR_RANGE_MSG)) > + return false; > + while (n_bytes) { > + struct page *page; > + uintptr_t base; > + uintptr_t offset; > + uintptr_t offset_complement; > + > + local_irq_save(flags); > + page = virt_to_page(d); > + offset = d & ~PAGE_MASK; > + offset_complement = PAGE_SIZE - offset; > + size = min(n_bytes, offset_complement); > + base = (uintptr_t)vmap(&page, 1, VM_MAP, PAGE_KERNEL); > + if (WARN(!base, WR_ERR_PAGE_MSG)) { > + local_irq_restore(flags); > + return false; > + } > + memset((void *)(base + offset), c, size); > + vunmap((void *)base); BUG > + d += size; > + n_bytes -= size; > + local_irq_restore(flags); > + } > + return true; > +} > + > +static __always_inline Similarly large > +bool wr_memcpy(const void *dst, const void *src, size_t n_bytes) > +{ > + size_t size; > + unsigned long flags; > + uintptr_t d = (uintptr_t)dst; > + uintptr_t s = (uintptr_t)src; > + > + if (WARN(!__is_wr_after_init(dst, n_bytes), WR_ERR_RANGE_MSG)) > + return false; > + while (n_bytes) { > + struct page *page; > + uintptr_t base; > + uintptr_t offset; > + uintptr_t offset_complement; > + > + local_irq_save(flags); > + page = virt_to_page(d); > + offset = d & ~PAGE_MASK; > + offset_complement = PAGE_SIZE - offset; > + size = (size_t)min(n_bytes, offset_complement); > + base = (uintptr_t)vmap(&page, 1, VM_MAP, PAGE_KERNEL); > + if (WARN(!base, WR_ERR_PAGE_MSG)) { > + local_irq_restore(flags); > + return false; > + } > + __write_once_size((void *)(base + offset), (void *)s, size); > + vunmap((void *)base); Similarly BUG. > + d += size; > + s += size; > + n_bytes -= size; > + local_irq_restore(flags); > + } > + return true; > +} > +static __always_inline Guess what.. > +uintptr_t __wr_rcu_ptr(const void *dst_p_p, const void *src_p) > +{ > + unsigned long flags; > + struct page *page; > + void *base; > + uintptr_t offset; > + const size_t size = sizeof(void *); > + > + if (WARN(!__is_wr_after_init(dst_p_p, size), WR_ERR_RANGE_MSG)) > + return (uintptr_t)NULL; > + local_irq_save(flags); > + page = virt_to_page(dst_p_p); > + offset = (uintptr_t)dst_p_p & ~PAGE_MASK; > + base = vmap(&page, 1, VM_MAP, PAGE_KERNEL); > + if (WARN(!base, WR_ERR_PAGE_MSG)) { > + local_irq_restore(flags); > + return (uintptr_t)NULL; > + } > + rcu_assign_pointer((*(void **)(offset + (uintptr_t)base)), src_p); > + vunmap(base); Also still bug. > + local_irq_restore(flags); > + return (uintptr_t)src_p; > +} Also, I see an amount of duplication here that shows you're not nearly lazy enough.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.