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]
Date:	Sun, 04 Nov 2012 18:38:29 +0800
From:	Shan Wei <shanwei88@...il.com>
To:	paulmck@...ux.vnet.ibm.com
CC:	Christoph Lameter <cl@...ux.com>, dipankar@...ibm.com,
	Kernel-Maillist <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 6/9] rcu: use __this_cpu_read helper instead of per_cpu_ptr(p,
 raw_smp_processor_id())

Paul E. McKenney said, at 2012/11/3 17:19:
> OK, I do understand why it happens to work.  My question is instead why
> it is considered a good idea.  

Maybe objdump gives the answer.
 __this_cpu_read which read member pointer of per-cpu variable
can reduce two instructions on x86-64 arch.


*test code:* 
struct eater_state {
        u32 state;
        struct eater __percpu *eater_info;
};

struct eater {
        char name[4];
        u32 age;
};

static u32 test_func(struct eater_state *tstas)
{
        struct eater *aeater;

        //aeater = __this_cpu_ptr(tstas->eater_info);   <-----------------1
        //return aeater->age;
        return  __this_cpu_read(tstas->eater_info->age); <-----------------2
}

static int __init demo_init(void)
{
        int ret = 0 ;
        int age;
        struct eater_state as;
        struct eater david;

        as.state = 1;
        as.eater_info = &david;

        age = test_func(&as);

        return ret;
}


__this_cpu_ptr <-----------------1
0000000000000000 <init_module>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 83 ec 10             sub    $0x10,%rsp
   8:   48 8d 45 f0             lea    -0x10(%rbp),%rax
   c:   65 48 03 04 25 00 00 00 00      add    %gs:0x0,%rax
  15:   31 c0                   xor    %eax,%eax
  17:   c9                      leaveq 
  18:   c3                      retq   


 __this_cpu_read<-----------------2
0000000000000000 <init_module>:
   0:   55                      push   %rbp
   1:   31 c0                   xor    %eax,%eax
   3:   48 89 e5                mov    %rsp,%rbp
   6:   48 83 ec 10             sub    $0x10,%rsp
   a:   c9                      leaveq 
   b:   c3                      retq   


--
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