From owner-freebsd-acpi@FreeBSD.ORG Thu Nov 22 14:53:29 2012 Return-Path: Delivered-To: freebsd-acpi@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C6624D6D; Thu, 22 Nov 2012 14:53:29 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id A57478FC13; Thu, 22 Nov 2012 14:53:28 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA24297; Thu, 22 Nov 2012 16:53:27 +0200 (EET) (envelope-from avg@FreeBSD.org) Message-ID: <50AE3C66.2050207@FreeBSD.org> Date: Thu, 22 Nov 2012 16:53:26 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2 MIME-Version: 1.0 To: freebsd-acpi@FreeBSD.org Subject: [rfc] bind curthread to target cpu for _CST change notification X-Enigmail-Version: 1.4.5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2012 14:53:29 -0000 I would like to propose the following patch which should kill two birds with one stone: - avoid race in acpi_cpu_cx_cst if more than one notifications occur in a rapid succession for the same CPU and end up being concurrently handled by ACPI taskqeue threads - avoid race acpi_cpu_cx_cst and acpi_cpu_idle where the latter may access resources being updated by the former What do you think? Index: sys/dev/acpica/acpi_cpu.c =================================================================== --- sys/dev/acpica/acpi_cpu.c (revision 242854) +++ sys/dev/acpica/acpi_cpu.c (working copy) @@ -1047,7 +1047,16 @@ return; /* Update the list of Cx states. */ + thread_lock(curthread); + sched_bind(curthread, sc->cpu_pcpu->pc_cpuid); + thread_unlock(curthread); + critical_enter(); acpi_cpu_cx_cst(sc); + critical_exit(); + thread_lock(curthread); + sched_unbind(curthread); + thread_unlock(curthread); + acpi_cpu_cx_list(sc); ACPI_SERIAL_BEGIN(cpu); -- Andriy Gapon