From owner-freebsd-acpi@FreeBSD.ORG Sun Nov 25 19:37:33 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 910F9B0; Sun, 25 Nov 2012 19:37:33 +0000 (UTC) (envelope-from seanwbruno@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 557698FC13; Sun, 25 Nov 2012 19:37:32 +0000 (UTC) Received: by mail-pb0-f54.google.com with SMTP id wz12so7679835pbc.13 for ; Sun, 25 Nov 2012 11:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:reply-to:to:cc:in-reply-to:references:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=GhjqBHN0xXY+FNKFsPPlr952Z6Gfmds6qf22BTar5d4=; b=m5mI9d5iFf8KTaBYwLKTAKGgwWQC4a/Pje+m8S6RkG1gl8xM+hVODMjsdPtBP1aaiY SF1RBTQ+U8eIauGSBuHs/AZQT5OIImFpGQxDZP466nfjOaVeJoe9oPY92p5uv5jRhmHw O46gN1yw5eBy6xWL9KvN4DYUlxSuuWKYY4dcp9h25KizTJnb5UCm/UyAqhsK/+Ayd0yx k412cEW8netpXihHydUPC6cqXhy/GBBQdELe3kubKvMDWAl/2qyE7prZuhgwjJhfycdf LCZwHMGNCzcUaXDRV8mkEvs6vmU9iOn3kLv1XuB5eex75wmYllZo1OhHstaMaYps7qzt gnnw== Received: by 10.66.85.10 with SMTP id d10mr26790563paz.52.1353872252573; Sun, 25 Nov 2012 11:37:32 -0800 (PST) Received: from [192.168.1.128] (c-71-202-40-63.hsd1.ca.comcast.net. [71.202.40.63]) by mx.google.com with ESMTPS id qj6sm7418477pbb.69.2012.11.25.11.37.31 (version=SSLv3 cipher=OTHER); Sun, 25 Nov 2012 11:37:31 -0800 (PST) Subject: Re: [rfc] bind curthread to target cpu for _CST change notification From: Sean Bruno To: Andriy Gapon In-Reply-To: <50AE3C66.2050207@FreeBSD.org> References: <50AE3C66.2050207@FreeBSD.org> Content-Type: text/plain; charset="UTF-8" Date: Sun, 25 Nov 2012 11:37:29 -0800 Message-ID: <1353872249.20189.3.camel@powernoodle> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-acpi@FreeBSD.org X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: sbruno@freebsd.org List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Nov 2012 19:37:33 -0000 On Thu, 2012-11-22 at 16:53 +0200, Andriy Gapon wrote: > 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); > Ack. This looks appropriate to me. Sean