From owner-freebsd-stable@FreeBSD.ORG Fri Jun 11 10:27:53 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 987431065674; Fri, 11 Jun 2010 10:27:53 +0000 (UTC) (envelope-from giovanni.trematerra@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 40C988FC1A; Fri, 11 Jun 2010 10:27:50 +0000 (UTC) Received: by fxm7 with SMTP id 7so670046fxm.13 for ; Fri, 11 Jun 2010 03:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=6K+1sJ5xK+VTOXOVSMd0CsyZossbAzd+Uz0N0VZa6wg=; b=orpJ0U+MYmzRwLdzCL8xoWQNk3uyff1C/+snG1cOV4Zul9VcNMrHvhNXzP/ql9eaxl MGoWE3S4I2NE3FyIaWAQmDt3QVbb7fyZ+9Qknvc77zKEEW4EhhXdcIKOLqR8DtyKChcj 8KPK9erEPh7q2rEHLtD/DFYQ9VVFCUxqTjick= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=PPbTEMeg9p7eW5J0VqI92P9wSmnvMqR1LAnBydp3Ygp7Wc0+UrFVqaPj5/FR2oJCm9 s3GV6xrd7CmwwkTy0/c0yL7BpAweon4IS6zfLas/L1Ru7mt24hFwB0LEeUCwxEAoUUbe QWXoBJwIlGCvyEoGd/cfnaoSa5gu8sDUmfEP4= MIME-Version: 1.0 Received: by 10.223.24.130 with SMTP id v2mr1599149fab.61.1276252068955; Fri, 11 Jun 2010 03:27:48 -0700 (PDT) Received: by 10.223.103.209 with HTTP; Fri, 11 Jun 2010 03:27:48 -0700 (PDT) In-Reply-To: References: <20100503224206.GB9134@icarus.home.lan> <20100504083738.GA23820@icarus.home.lan> <20100504085332.GA24219@icarus.home.lan> Date: Fri, 11 Jun 2010 12:27:48 +0200 Message-ID: From: Giovanni Trematerra To: freebsd-stable , John Baldwin , kib@freebsd.org, jkim@freebsd.org, avg@freebsd.org Content-Type: multipart/mixed; boundary=00151747357036c86b0488be97bd Cc: David DEMELIER , Brandon Gooch , Rui Paulo , Attilio Rao Subject: Re: Kernel panic when unpluggin AC adaptor X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2010 10:27:53 -0000 --00151747357036c86b0488be97bd Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Jun 10, 2010 at 10:58 PM, Giovanni Trematerra wrote: > On Tue, May 4, 2010 at 6:35 PM, David DEMELIER = wrote: >> Good news ! It worked, check the picture here : >> >> http://img63.imageshack.us/img63/4244/dsc00361g.jpg >> > > Into the file sys/dev/acpica/acpi_cpu.c at the end of acpi_cpu_notify > (a per cpu notification handler), called when _CST objects changing, > global cpu_cx_count is set to the greatest value of all sc->cpu_cx_count > per-cpu variables. That could result in a panic as David reported, > because that lets to invoke acpi_cpu_global_cx_lowest_sysctl from > /etc/rc.d/power_profile, when AC adapter is unplugged, =A0with a value > that not all the CPUs could handle in the acpi_cpu_idle. > The patch also change global cpu_cx_lowest according to new value of > global cpu_cx_count if needed. > > David Demelier made a great work to test every patch I sent him > to identify the source of the problem. > > Please, let me know your comments and possibly commit the patch > if you think is good enough. As jhb@ pointed me out in private with the previous patch a CPU could never enter in the lowest Cx-state even if it gained. So I'd like to propose this new solution. When hw.acpi.cpu.cx_lowest sysctl is set, the global handler in sys/dev/acpi_cpu.c will set the greatest sc->cpu_cx_lowest value supported by the CPU and not the same value for all CPUs. Later, when CPU, possibly gain new Cx-states, the acpi_cpu_notify handler will set sc->cpu_cx_lowest accordingly with global cx_lowest and the Cx-states supported by the CPU. Now I think that /etc/rc.d/power_profile script has a problem but that is a different story. The script select the lowest_value only querying cx-states of the dev.cpu.0= . If different CPUs may have different Cx-states, the script should use as lowest_value the lowest value between all the CPUs. Please, let me know your comments and possibly commit the patch if you think is good enough. -- Gianni --00151747357036c86b0488be97bd Content-Type: text/plain; charset=US-ASCII; name="acpi_cpu_notify4.diff.txt" Content-Disposition: attachment; filename="acpi_cpu_notify4.diff.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gaauzzri1 ZGlmZiAtciBhYzk1YTczZDM1OGQgc3lzL2Rldi9hY3BpY2EvYWNwaV9jcHUuYwotLS0gYS9zeXMv ZGV2L2FjcGljYS9hY3BpX2NwdS5jCVR1ZSBNYXkgMTggMDg6MTM6NDAgMjAxMCAtMDQwMAorKysg Yi9zeXMvZGV2L2FjcGljYS9hY3BpX2NwdS5jCUZyaSBKdW4gMTEgMDM6MTA6MzcgMjAxMCAtMDQw MApAQCAtMTAwOSw2ICsxMDA5LDggQEAgYWNwaV9jcHVfbm90aWZ5KEFDUElfSEFORExFIGgsIFVJ TlQzMiBubwogCWlmIChpc2MtPmNwdV9jeF9jb3VudCA+IGNwdV9jeF9jb3VudCkKIAkgICAgY3B1 X2N4X2NvdW50ID0gaXNjLT5jcHVfY3hfY291bnQ7CiAgICAgfQorICAgIGlmIChzYy0+Y3B1X2N4 X2xvd2VzdCA8IGNwdV9jeF9sb3dlc3QpCisJYWNwaV9jcHVfc2V0X2N4X2xvd2VzdChzYywgbWlu KGNwdV9jeF9sb3dlc3QsIHNjLT5jcHVfY3hfY291bnQgLSAxKSk7CiAgICAgQUNQSV9TRVJJQUxf RU5EKGNwdSk7CiB9CiAKQEAgLTEyMDQsNyArMTIwNiw3IEBAIGFjcGlfY3B1X2dsb2JhbF9jeF9s b3dlc3Rfc3lzY3RsKFNZU0NUTF8KICAgICBBQ1BJX1NFUklBTF9CRUdJTihjcHUpOwogICAgIGZv ciAoaSA9IDA7IGkgPCBjcHVfbmRldmljZXM7IGkrKykgewogCXNjID0gZGV2aWNlX2dldF9zb2Z0 YyhjcHVfZGV2aWNlc1tpXSk7Ci0JYWNwaV9jcHVfc2V0X2N4X2xvd2VzdChzYywgdmFsKTsKKwlh Y3BpX2NwdV9zZXRfY3hfbG93ZXN0KHNjLCBtaW4odmFsLCBzYy0+Y3B1X2N4X2NvdW50IC0gMSkp OwogICAgIH0KICAgICBBQ1BJX1NFUklBTF9FTkQoY3B1KTsKIAo= --00151747357036c86b0488be97bd--