From owner-freebsd-hackers@freebsd.org Fri Jul 8 12:03:03 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE8D3B8250A for ; Fri, 8 Jul 2016 12:03:03 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-qk0-x244.google.com (mail-qk0-x244.google.com [IPv6:2607:f8b0:400d:c09::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A71E41AC1 for ; Fri, 8 Jul 2016 12:03:03 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: by mail-qk0-x244.google.com with SMTP id r68so8132632qka.3 for ; Fri, 08 Jul 2016 05:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+8WPtPHos/Yoz950VJ4JznavMv6epPfdv3QnK2qd3pQ=; b=IIP3I39P3FTF6HCmQx9rhUfrB/vRVrXTMIEoEEKRFj4zQpfONI2VckolpdVJlhmLNv Yr09Qr/jYjmKoIqsldUkvsJhnR0GD8eIyKFBkWf3TxJnoV0ChZmoT/Znkth6Kd48tSOv jpgCR/S3rS23v4HWgxQFMF9yLoJr3jsZUHrRZo1BUx4333O+veDaemFVacALEEwWcUXb urcCo7UbgwN82VW3agOdza7bIMtdlwBD5DxPGlqcqLRkLWIKDf0FsxNdee5YfaE3mO47 Z8tIdeYxXKV+fQCH31v+WnR14UOFjy94fZ4ivLgPccFAxcNT+RdIQuCWFHKrpJUtlA2M Z4MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+8WPtPHos/Yoz950VJ4JznavMv6epPfdv3QnK2qd3pQ=; b=kxUWgP3/3GC6rUqVmoIEpk1W0gClKVs9VSbBT5JtDQMzPmbl83xNvCDOu/ankU+euc btmOIC6OVGzwqR6z8YRbKFlN7oclsd9BFx1JA1rWiE22wDIOBj0dvnRSJgWlcqGWGqsD svXH9yG71wupmwhAsUN2MMC1euB60jni80X4IgFE7aJJ7RnjVpaak+V+ATq29fsFJyMc fD9IODOLgGxqa4DugOkwsyk8MxrkEOn0j7HycEhEFPq51Hik3/grn+mQr6+Ht9Qn2s8S TdKjafHcO5eKxpLilRpiLJawHmkwxFQTwV79QZGxjssDG4NP06i1U0N1NlbBnqsLf0/u Kj+A== X-Gm-Message-State: ALyK8tL+QRlxMBZudMNzJQeZF0TN9McvcE7LOVVAK9+ehPBSg+gDIIuWiFGEicOGSl1Eww== X-Received: by 10.194.200.100 with SMTP id jr4mr5025403wjc.176.1467979382321; Fri, 08 Jul 2016 05:03:02 -0700 (PDT) Received: from gumby.homeunix.com ([81.171.97.59]) by smtp.gmail.com with ESMTPSA id x83sm2718546wmx.9.2016.07.08.05.03.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2016 05:03:01 -0700 (PDT) Date: Fri, 8 Jul 2016 13:02:58 +0100 From: RW To: freebsd-hackers@freebsd.org Subject: Re: Why kinfo_getvmmap is sometimes so expensive? Message-ID: <20160708130258.7b772558@gumby.homeunix.com> In-Reply-To: <6193bbf3-39cd-abaa-a5e4-0480c40dac55@rawbw.com> References: <20160707001913.GJ38613@kib.kiev.ua> <6193bbf3-39cd-abaa-a5e4-0480c40dac55@rawbw.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; amd64-portbld-freebsd10.2) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2016 12:03:04 -0000 On Thu, 7 Jul 2016 15:32:28 -0700 Yuri wrote: > On 07/06/2016 17:19, Konstantin Belousov wrote: > > To calculate residency count for the process map entries, kernel > > has to iterate over all pages. This operation was somewhat > > optimized in 10.3 and HEAD, particularly for the large sparce > > mappings. But for large populated mappings there is no other way > > then to check each page. > > > > You may confirm my hypothesis by setting sysctl > > kern.proc_vmmap_skip_resident_count to 0 and see whether the CPU > > consumption changed. Of course, you will not get the resident count > > in the returned structure, after the knob is tweaked. > > > When people raise the question of why malloc library doesn't unmap > the memory, developers there usually say that they call > madvise(MADV_FREE) and this is as good as unmap. It's better than unmapping because freed memory is commonly re-malloced shortly after it's freed. > But this example > shows that this isn't quite the case on the FreeBSD, and unmapping is > better. That doesn't mean it's better in general.