From owner-freebsd-acpi@FreeBSD.ORG Sun Jun 20 16:09:45 2010 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61FF9106566C; Sun, 20 Jun 2010 16:09:45 +0000 (UTC) (envelope-from mavbsd@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 B94ED8FC0C; Sun, 20 Jun 2010 16:09:44 +0000 (UTC) Received: by fxm7 with SMTP id 7so1838852fxm.13 for ; Sun, 20 Jun 2010 09:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=A6U8c4EqbXgACGzJ9kGrrl+2jxnw41xpESb1ernwciQ=; b=BxpzN05ue6Tdr6AxeG+8ZxCPcTj2EZ7AJ670Q4zNcic1OYkIIro3dvoKsY2hb7/0xx 0UAUA9ePePclpAKG4VBFfjD9bWhtHcRJzBfdYH2ATiqnBkmFgBHr0AjnSE1PZ2yGKWP0 dd0pXqojFlrJHU1N3LOReOQ+/x2MMysB6Y3o8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=fT/rlxezWsebR57iHLPv1+ODwfM4hglBkMUr78KV4q50nPJyxlGLDcr++SDHcgB6f4 XNEeqvbFGFwgzMI3kTFUew4IUNXQtnE1x4XTz9w09cyfZq53AK1iXUwg8VhP86fS08ut +2S48ydMBCoRaX8CaOrJMMPsCuCa13NVzm1sM= Received: by 10.223.68.131 with SMTP id v3mr3916889fai.82.1277050183084; Sun, 20 Jun 2010 09:09:43 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id 27sm25223144faz.18.2010.06.20.09.09.42 (version=SSLv3 cipher=RC4-MD5); Sun, 20 Jun 2010 09:09:42 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C1E3D44.6020708@FreeBSD.org> Date: Sun, 20 Jun 2010 19:09:40 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.24 (X11/20100402) MIME-Version: 1.0 To: Andriy Gapon References: <4C1E3AE9.3020505@freebsd.org> In-Reply-To: <4C1E3AE9.3020505@freebsd.org> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-acpi@freebsd.org Subject: Re: cpufreq_curr_sysctl: memory allocation X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Jun 2010 16:09:45 -0000 Andriy Gapon wrote: > I noticed that cpufreq_curr_sysctl performs a substantial memory allocation and > deallocation on each call. Its size is CF_MAX_LEVELS * sizeof(*levels), which > is ~24KB. This happens even for read-only calls to just query current level. > And such calls happen quite frequently when powerd is running. Worse is that it not just consumes time, but causes a bunch or TLB flush IPIs on free(). For read-only call it doesn't even needs CF_MAX_LEVELS * sizeof(*levels). sizeof(*levels) seems should be enough there. May be then it fits into some existing UMA zone, minimizing penalty. > I think that this is an unnecessary and avoidable load for VM system. > Couldn't a buffer be preallocated in sc and re-used for the calls? > Even if not, for some reason, then wouldn't it be better to have a dedicated uma > zone for that rather than doing malloc+free? Dedicated rarely used UMA zone may eat much more memory then it is needed on SMP. -- Alexander Motin