From owner-freebsd-current@FreeBSD.ORG Sat Nov 30 01:11:53 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 35E16FAA; Sat, 30 Nov 2013 01:11:53 +0000 (UTC) Received: from mail-lb0-x230.google.com (mail-lb0-x230.google.com [IPv6:2a00:1450:4010:c04::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 83A251B12; Sat, 30 Nov 2013 01:11:52 +0000 (UTC) Received: by mail-lb0-f176.google.com with SMTP id x18so7264324lbi.21 for ; Fri, 29 Nov 2013 17:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=idjeLnOWnX6+ivoH80Cyd/9Hf7Y0l7vYZffxw6EAK94=; b=ktW+Rr3bS3axRu+EPjmU48cuLQyme2RWM5JXuIv7GacZ6tK6bj0z/qWPmZXwc2k10t OogCl9it4YsU+3nQS6vh+kGfq0vPty9SMETkRCqYvfpo8vpDC0ZdSp+2n01yt02ZnkuV RWryHUoNO+NIykiUyFSJoQIUZrnYEJbyxsEafqWuY20MZEX6QsAxGVGstDK08c3T59uv vnOoecQhwaLeYlyQsp4pK+CakNpVmJavMHH20ytDknAGh/8WeA5DwjhJWQvP/3NE0xMV TeeXwENobdE3HKy6RSe3Mv7cRP67QFg9x0ztpTHklHZrlczFRGd5/cYpWXH7acn24Vi1 zr6w== MIME-Version: 1.0 X-Received: by 10.112.63.40 with SMTP id d8mr11706lbs.35.1385773909710; Fri, 29 Nov 2013 17:11:49 -0800 (PST) Sender: rizzo.unipi@gmail.com Received: by 10.114.175.180 with HTTP; Fri, 29 Nov 2013 17:11:49 -0800 (PST) In-Reply-To: References: Date: Fri, 29 Nov 2013 17:11:49 -0800 X-Google-Sender-Auth: ivVDAljsiQOAEkug_MZyILnVr3I Message-ID: Subject: Re: [RFC] how to get the size of a malloc(9) block ? From: Luigi Rizzo To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.16 Cc: freebsd-current , jb X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Nov 2013 01:11:53 -0000 On Fri, Nov 29, 2013 at 4:49 PM, Adrian Chadd wrote: > The reason I wouldn't implement this is to avoid having code that > _relies_ on this behaviour in order to function or perform well. > nobody ever said (or could reasonably expect to do) that. Applications don't know if the allocator overallocates, so they have no hope unless they work even without the feature. This is only about giving them an option to improve performance in those (rare ?) cases where, as i showed, knowing the underlying allocation size may lead to better usage of memory. > > Heck, it may not even be portable to other operating systems. Except, > Linux, I guess. > > in userspace, as jb commented, all major OSes have it (malloc_usable_size() on FreeBSD and Linux, _msize() on Windows, malloc_size() on OSX). In the kernel, I have no idea, but porting kernel code across systems is a nightmare anyways... cheers luigi