Messages in this thread |  | | Date | Tue, 17 Dec 2019 09:47:39 +0800 (GMT+08:00) | From | 孙国云 <> | Subject | Re: Re: [PATCH V3] MIPS: Add get_thread_area syscall |
| |
Dear Paul,
Thank you very much. I didn`t know this way asm("rdhwr %0, $29" : "=r"(*ptls)) before.Now I have a test for it and it realy can work normally. I just find get_thread_area syscall at path arch/x86.so I have a implement on MIPS platform. And I think set_thread_area and get_thread_area is matched in pairs. Now it seems that the get_thread_area syscall is not necessary for criu.
Thanks, Guoyun Sun
> -----原始邮件----- > 发件人: "Paul Burton" <paulburton@kernel.org> > 发送时间: 2019-12-17 03:33:33 (星期二) > 收件人: "Guoyun Sun" <sunguoyun@loongson.cn> > 抄送: "Ralf Baechle" <ralf@linux-mips.org>, "James Hogan" <jhogan@kernel.org>, "Peter Zijlstra" <peterz@infradead.org>, "Christian Brauner" <christian.brauner@ubuntu.com>, "Arnd Bergmann" <arnd@arndb.de>, "Heiko Carstens" <heiko.carstens@de.ibm.com>, "David Howells" <dhowells@redhat.com>, "Geert Uytterhoeven" <geert@linux-m68k.org>, "Catalin Marinas" <catalin.marinas@arm.com>, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, "Tiezhu Yang" <yangtiezhu@loongson.cn>, "Xuefeng Li" <lixuefeng@loongson.cn> > 主题: Re: [PATCH V3] MIPS: Add get_thread_area syscall > > Hi Guoyun, > > On Mon, Dec 16, 2019 at 10:17:51AM +0800, Guoyun Sun wrote: > > CRIU(https://criu.org/) tools will dump TLS(Thread Local Storage) by > > get_thread_area during checkpoint and restore TLS by set_thread_area during > > restore. without this syscall, criu restore will fail on MIPS platform > > because a variable with GCC __thread will be invalid. > > > > The following function will be called when criu restore > > > > static inline void restore_tls(tls_t *ptls) { > > asm volatile( > > "move $4, %0 \n" > > "li $2, "__stringify(__NR_set_thread_area)" \n" > > "syscall \n" > > : > > : "r"(*ptls) > > : "$4","$2","memory"); > > > > the *ptls can be obtained by get_thread_area on MIPS platform when criu > > checkpoint. just like this: > > > > static inline void arch_get_tls(tls_t *ptls) > > { > > asm volatile( > > "move $4, %0 \n" > > "li $2, "__stringify(__NR_get_thread_area)" \n" > > "syscall \n" > > : > > : "r"(ptls) > > : "$4","$2","memory"); > > > > } > > Why would you need a syscall for this? > > Why not retrieve the value using the rdhwr instruction just like every > other bit of code using thread-local storage does? > > ie. something like: > > static inline void arch_get_tls(tls_t *ptls) > { > asm("rdhwr %0, $29" : "=r"(*ptls)); > } > > Thanks, > Paul </lixuefeng@loongson.cn></yangtiezhu@loongson.cn></catalin.marinas@arm.com></geert@linux-m68k.org></dhowells@redhat.com></heiko.carstens@de.ibm.com></arnd@arndb.de></christian.brauner@ubuntu.com></peterz@infradead.org></jhogan@kernel.org></ralf@linux-mips.org></sunguoyun@loongson.cn></paulburton@kernel.org> |  |