From owner-svn-src-head@freebsd.org Sat Nov 11 11:01:51 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEB8FE67FD8; Sat, 11 Nov 2017 11:01:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B60247D521; Sat, 11 Nov 2017 11:01:51 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vABB1oKx057150; Sat, 11 Nov 2017 11:01:50 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vABB1oXM057147; Sat, 11 Nov 2017 11:01:50 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201711111101.vABB1oXM057147@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 11 Nov 2017 11:01:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r325708 - in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/sys/compat/linuxkpi/common: include/linux src X-SVN-Commit-Revision: 325708 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Nov 2017 11:01:52 -0000 Author: hselasky Date: Sat Nov 11 11:01:50 2017 New Revision: 325708 URL: https://svnweb.freebsd.org/changeset/base/325708 Log: Remove release and acquire semantics when accessing the "state" field of the LinuxKPI task struct. Change type of "state" variable from "int" to "atomic_t" to simplify code and avoid unneccessary casting. MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h head/sys/compat/linuxkpi/common/src/linux_current.c head/sys/compat/linuxkpi/common/src/linux_schedule.c Modified: head/sys/compat/linuxkpi/common/include/linux/sched.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/sched.h Sat Nov 11 10:46:12 2017 (r325707) +++ head/sys/compat/linuxkpi/common/include/linux/sched.h Sat Nov 11 11:01:50 2017 (r325708) @@ -67,7 +67,7 @@ struct task_struct { void *task_data; int task_ret; atomic_t usage; - int state; + atomic_t state; atomic_t kthread_flags; pid_t pid; /* BSD thread ID */ const char *comm; @@ -92,9 +92,8 @@ struct task_struct { #define put_pid(x) do { } while (0) #define current_euid() (curthread->td_ucred->cr_uid) -#define set_task_state(task, x) \ - atomic_store_rel_int((volatile int *)&task->state, (x)) -#define __set_task_state(task, x) (task->state = (x)) +#define set_task_state(task, x) atomic_set(&(task)->state, (x)) +#define __set_task_state(task, x) ((task)->state.counter = (x)) #define set_current_state(x) set_task_state(current, x) #define __set_current_state(x) __set_task_state(current, x) Modified: head/sys/compat/linuxkpi/common/src/linux_current.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_current.c Sat Nov 11 10:46:12 2017 (r325707) +++ head/sys/compat/linuxkpi/common/src/linux_current.c Sat Nov 11 11:01:50 2017 (r325708) @@ -68,7 +68,7 @@ linux_alloc_current(struct thread *td, int flags) ts->comm = td->td_name; ts->pid = td->td_tid; atomic_set(&ts->usage, 1); - ts->state = TASK_RUNNING; + atomic_set(&ts->state, TASK_RUNNING); init_completion(&ts->parked); init_completion(&ts->exited); Modified: head/sys/compat/linuxkpi/common/src/linux_schedule.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_schedule.c Sat Nov 11 10:46:12 2017 (r325707) +++ head/sys/compat/linuxkpi/common/src/linux_schedule.c Sat Nov 11 11:01:50 2017 (r325708) @@ -78,7 +78,7 @@ wake_up_task(struct task_struct *task, unsigned int st ret = wakeup_swapper = 0; sleepq_lock(task); - if ((atomic_load_acq_int(&task->state) & state) != 0) { + if ((atomic_read(&task->state) & state) != 0) { set_task_state(task, TASK_WAKING); wakeup_swapper = sleepq_signal(task, SLEEPQ_SLEEP, 0, 0); ret = 1; @@ -234,7 +234,7 @@ linux_wait_event_common(wait_queue_head_t *wqh, wait_q */ PHOLD(task->task_thread->td_proc); sleepq_lock(task); - if (atomic_load_acq_int(&task->state) != TASK_WAKING) { + if (atomic_read(&task->state) != TASK_WAKING) { ret = linux_add_to_sleepqueue(task, "wevent", timeout, state); } else { sleepq_release(task); @@ -269,7 +269,7 @@ linux_schedule_timeout(int timeout) DROP_GIANT(); sleepq_lock(task); - state = atomic_load_acq_int(&task->state); + state = atomic_read(&task->state); if (state != TASK_WAKING) (void)linux_add_to_sleepqueue(task, "sched", timeout, state); else