Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6372416yba; Tue, 14 May 2019 06:34:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFN8OOxEWSuWoCfjKN6qjZstpSuu1Wsli+5RldRWDC3GLVGTAJm88wwI1HgIYRZOiH2XqW X-Received: by 2002:a63:3:: with SMTP id 3mr37270921pga.360.1557840884708; Tue, 14 May 2019 06:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557840884; cv=none; d=google.com; s=arc-20160816; b=0uciY82VkzZ/8EXNl9+4AczyTSnCfiaVDFGW8igxTgF4snbGh8x4NDfWxf79kz5CCr HxU5OphV4aGnVl5/oXN3hOdfHBH7jBg0ZKLr85GOxyqIa4w4G2WizjRbDUXMRRuYdOSx yvsBGdP9v4VnwDjEPc9livkeEoF35VtaMsujKlxTNcOijkg6gcJWZGzFZK45/Jl1nzlz EGlHqDV3rhU5/qhzagJDTUIRjZSst0utkv3kcHVn7FdLxb39vtLyncid15JtTBACnnGQ mnxzJ52NuF1PgAjmlw2m4B7xLM8u7afTemT4Uwjv/FPylmqvkhzK2WTk/XWomOA8d6Di ikag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=d9EoIX4OtN63tuf6PqPnEv+P68EjjjVZjk7X2yNFHPw=; b=Z9zICG9kqWC+/o3vU3j/xJch/+bEXceh4OvC0+DkUvp7Qu/tvdFq6Gn5vwkWP5mgR5 tiOflOMBnMVa2W1FbztMylC+1Y4P2FJ1Q+NVaJU/dYUxesCmoySwtB1FHUcnE2naB6mK D/Pq5Kt0WbNM71DbVot0K7ktXI6PJWFAI0o+911DWjexHV7wDEtoiiZ1qdf7GB3pBOcU wmcg0FUfXjIMiFrd5oRHbpb4zq2G93zdmMJrX7uKL9Wr25FTQc8dpWBQFK/Pzhysgnfu uYu7uy3CasVX+6wd5iy683Mox3hTxOzbJb/LQDeMnVqlnKjF97rDBSdup6lhJuNEfV5m 8MSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f22si20106754pgk.376.2019.05.14.06.34.29; Tue, 14 May 2019 06:34:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726089AbfENNdX (ORCPT + 99 others); Tue, 14 May 2019 09:33:23 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55552 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbfENNdW (ORCPT ); Tue, 14 May 2019 09:33:22 -0400 Received: by mail-wm1-f68.google.com with SMTP id x64so2890323wmb.5 for ; Tue, 14 May 2019 06:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=d9EoIX4OtN63tuf6PqPnEv+P68EjjjVZjk7X2yNFHPw=; b=WHw6utQ1Ksb9eNJLcAXPGnNfOi2mN1CkRshQb1izkYSq48LhIz0A78ujFhS3cKeUEj EKk5Z9hePWhe2mgrG/qdWIU3/lAU+KJBE5u+bh/o9VbS8syr2TqMcEEwynnrfR+0X723 OMEde0SiBFUiB4dkt5msum0rzly+dQul9K2PrS4uICJiad1+CLKBQryK8maP55Hy/uBX 5gkLToOLNG8WI6rvb1atpt/Rj4et5wp7E8UZkyAQHKrBECmntvvldOEn7pLnLC36hVJM 3Otm+yYOKnC1hFOxhRrvuw30qNrcRtx6aqFg54o4Lq2dLI8XdsIKvv43OtSAIYwIMk+r HPkQ== X-Gm-Message-State: APjAAAUI8Koo4FosT+qUszJwM5g3zBD1V/2Us4gMMgJjNfyFu0qgz4jM YRREOeynNxHUTetRnTHBEjKds1IqHbcO3w== X-Received: by 2002:a1c:f312:: with SMTP id q18mr18961502wmq.96.1557840800371; Tue, 14 May 2019 06:33:20 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id a6sm13803254wrp.49.2019.05.14.06.33.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 06:33:19 -0700 (PDT) Date: Tue, 14 May 2019 15:33:18 +0200 From: Oleksandr Natalenko To: Kirill Tkhai Cc: linux-kernel@vger.kernel.org, Vlastimil Babka , Michal Hocko , Matthew Wilcox , Pavel Tatashin , Timofey Titovets , Aaron Tomlin , linux-mm@kvack.org Subject: Re: [PATCH RFC 0/4] mm/ksm: add option to automerge VMAs Message-ID: <20190514133318.6ajp3jn22jqowt4p@butterfly.localdomain> References: <20190510072125.18059-1-oleksandr@redhat.com> <36a71f93-5a32-b154-b01d-2a420bca2679@virtuozzo.com> <20190513113314.lddxv4kv5ajjldae@butterfly.localdomain> <20190514063043.ojhsb6d3ohxx4wur@butterfly.localdomain> <8f146863-5963-81b2-ed20-6428d1da353c@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8f146863-5963-81b2-ed20-6428d1da353c@virtuozzo.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi. On Tue, May 14, 2019 at 12:12:16PM +0300, Kirill Tkhai wrote: > > Immediate question: what should be actually done on this? I see 2 > > options: > > > > 1) mark all VMAs as mergeable + set some flag for mmap() to mark all > > further allocations as mergeable as well; > > 2) just mark all the VMAs as mergeable; userspace can call this > > periodically to mark new VMAs. > > > > My prediction is that 2) is less destructive, and the decision is > > preserved predominantly to userspace, thus it would be a desired option. > > Let's see, how we use KSM now. It's good for virtual machines: people > install the same distribution in several VMs, and they have the same > packages and the same files. When you read a file inside VM, its pages > are file cache for the VM, but they are anonymous pages for host kernel. > > Hypervisor marks VM memory as mergeable, and host KSM merges the same > anonymous pages together. Many of file cache inside VM is constant > content, so we have good KSM compression on such the file pages. > The result we have is explainable and expected. Yup, correct. > But we don't know anything about pages, you have merged on your laptop. > We can't make any assumptions before analysis of applications, which > produce such the pages. Let's check what happens before we try to implement > some specific design (if we really need something to implement). > > The rest is just technical details. We may implement everything we need > on top of this (even implement a polling of /proc/[pid]/maps and write > a task and address of vma to force_madvise or similar file). I'm not sure that reviewing all the applications falls under the scope of this and/or similar submission. Personally I do not feel comfortable reviewing Firefox code, for example. But I do run 2 instances of FF, one for work stuff, one for personal stuff, so merging its memory would be definitely beneficial for me. I believe I'm not the only one doing this, and things are not limited to Firefox only, of course. Please consider checking a v2 submission I've just posted. It implements your suggestion on "force_madvise" knob, and I find your feedback very relevant and useful. Thanks. -- Best regards, Oleksandr Natalenko (post-factum) Senior Software Maintenance Engineer