linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Burton <paulburton@kernel.org>
To: Guoyun Sun <sunguoyun@loongson.cn>
Cc: 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>
Subject: Re: [PATCH V3] MIPS: Add get_thread_area syscall
Date: Mon, 16 Dec 2019 11:33:33 -0800	[thread overview]
Message-ID: <20191216193333.up4qqzxno23pbzix@lantea.localdomain> (raw)
In-Reply-To: <1576462671-7226-1-git-send-email-sunguoyun@loongson.cn>

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

  reply	other threads:[~2019-12-16 19:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16  2:17 [PATCH V3] MIPS: Add get_thread_area syscall Guoyun Sun
2019-12-16 19:33 ` Paul Burton [this message]
2019-12-17  1:47   ` 孙国云

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191216193333.up4qqzxno23pbzix@lantea.localdomain \
    --to=paulburton@kernel.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=peterz@infradead.org \
    --cc=ralf@linux-mips.org \
    --cc=sunguoyun@loongson.cn \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).