lkml.org 
[lkml]   [2018]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH net-next v3 01/17] asm: simd context helper API
    On Mon, Sep 10, 2018 at 07:08:21PM -0600, Jason A. Donenfeld wrote:
    > Sometimes it's useful to amortize calls to XSAVE/XRSTOR and the related
    > FPU/SIMD functions over a number of calls, because FPU restoration is
    > quite expensive. This adds a simple header for carrying out this pattern:
    >
    > simd_context_t simd_context = simd_get();
    > while ((item = get_item_from_queue()) != NULL) {
    > encrypt_item(item, simd_context);
    > simd_context = simd_relax(simd_context);
    > }
    > simd_put(simd_context);
    >
    > The relaxation step ensures that we don't trample over preemption, and
    > the get/put API should be a familiar paradigm in the kernel.

    Given that it's always supposed to be used like that, mightn't it be
    better if simd_relax() took a pointer to the context, so the call is
    just

    simd_relax(&simd_context);

    ?

    The inlining means that there won't actually be a pointer dereference in
    the emitted code.

    If simd_put() also took a pointer then it could set the context back to
    HAVE_NO_SIMD as well?

    - Kevin

    \
     
     \ /
      Last update: 2018-09-12 08:23    [W:4.689 / U:0.184 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site