Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2398232ybh; Mon, 16 Mar 2020 02:22:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvIFeHCQAprLPnD31WczOk7L1TZ49n3hvVYXtmvIfrvCiyu4PozDqr8uvyW0LL5fVmfgEr0 X-Received: by 2002:aca:dac5:: with SMTP id r188mr5472143oig.176.1584350558805; Mon, 16 Mar 2020 02:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584350558; cv=none; d=google.com; s=arc-20160816; b=fZgJwm5M1TbrgCimByRBaRmAabzQP/YpqGba5RTVl9dKn0mx7y+gnnG5VM2PAU6L2W WGGIsw+emarM610A6AlUzTp0DxzHgE/5zSW7zEk70FwhqHhrwTZlV1CRDjw618QWXJrq U62OLDgOuwivaPxyDoY6ELSZX0O4vxHg1tm1wpn8VwsL6lcPQiHdFtyPPeopjLvzsn9k GrNaV6fky/VjEb0EswgUUEN/YACeJtsYCIivXE6g5x0F/3TeDU48lqc2Llz2h22I9csn TpiuDSKBYZixSjZpAU1BZGy7U3ZesUtcmz51rM+VzQ52QnwWbWAjNrXWav7xqNfGZJJs qOZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=gpxt45thOiwYDJ5g1pO2m1tlgc7KWRmLIsWLSSokj8o=; b=CsTHib4M1+QHBEBaony26HNlO/g39Y0+eShJU23WpCs2wKb8xBRFh1rp5T0Wz1FGVh bvtp3ULghPeKhhM03hV1P7MzCb5Ibj466buIa6QRwilJbe4DcaFJ17nq8buQW+fvTeBF bTkL7W/uFRqV55NrUA8v+o2w7nVihOFl9Fzcbqy1BP50+brq/NGnw/jJYX46R5l3eIqM wfGLY23FjcQu7ZTfgRgAVJEUVltq7/gKr9Uq0NOHVsbr74iT+oNZo56ZIVCF/+INUgga G0RhqRYGbHRXLMbIPEYfjOkCaYRpbzvmldq+IsXdMywbv+yKOigUkti0FYwMtwntiOe1 i6tQ== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si8548701otn.181.2020.03.16.02.22.26; Mon, 16 Mar 2020 02:22:38 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730396AbgCPJVE (ORCPT + 99 others); Mon, 16 Mar 2020 05:21:04 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]:38786 "EHLO mail-wm1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730152AbgCPJVD (ORCPT ); Mon, 16 Mar 2020 05:21:03 -0400 Received: by mail-wm1-f48.google.com with SMTP id t13so10754379wmi.3 for ; Mon, 16 Mar 2020 02:21:01 -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; bh=gpxt45thOiwYDJ5g1pO2m1tlgc7KWRmLIsWLSSokj8o=; b=a34CS7VoB/TMeaBCvOm5KPRVQ+kQOgBW5lUv9LIO0wMHGpr50KckMKs0tKeurgba22 HQxFUfG9e/LxImo6MrouP5kDzJtqv7lw5I4kv+YchBihVrDfoTaxuJVEhTIAZvD1MvLk Peplh3z0NSLbUqZIzehc3qIt4NHQKxiIUZ3GYVWuMys+scCe6RPPOWa3qWcGMmcdFk9b rZNl5hABVyS3nI4oGv3vPRI9cMGfS188D1d9Ysis40SW/pb5EG+55y6WhJhEgcQ8mcOQ k5+l2Iedzk2MBaw+JyvK8HceDeckILLUvD1T52+oMPFYj53/cRo7K2K04WLO6dWUJM6E Gt5w== X-Gm-Message-State: ANhLgQ2ta6La9oVd22KDKxpOUyscLU3cXaSlHYuYmGYgruGxrZRRKHry m/DamKMZE4Qw0v2qSR5sKyvqXVdP X-Received: by 2002:a1c:156:: with SMTP id 83mr27637518wmb.151.1584350460481; Mon, 16 Mar 2020 02:21:00 -0700 (PDT) Received: from localhost (ip-37-188-254-25.eurotel.cz. [37.188.254.25]) by smtp.gmail.com with ESMTPSA id b5sm22221872wrw.86.2020.03.16.02.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2020 02:20:59 -0700 (PDT) Date: Mon, 16 Mar 2020 10:20:52 +0100 From: Michal Hocko To: Minchan Kim Cc: Jann Horn , Linux-MM , kernel list , Daniel Colascione , Dave Hansen , "Joel Fernandes (Google)" , Andrew Morton Subject: Re: interaction of MADV_PAGEOUT with CoW anonymous mappings? Message-ID: <20200316092052.GD11482@dhcp22.suse.cz> References: <20200312082248.GS23944@dhcp22.suse.cz> <20200312201602.GA68817@google.com> <20200312204155.GE23944@dhcp22.suse.cz> <20200313020851.GD68817@google.com> <20200313080546.GA21007@dhcp22.suse.cz> <20200313205941.GA78185@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200313205941.GA78185@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 13-03-20 13:59:41, Minchan Kim wrote: > On Fri, Mar 13, 2020 at 09:05:46AM +0100, Michal Hocko wrote: > > On Thu 12-03-20 19:08:51, Minchan Kim wrote: > > > On Thu, Mar 12, 2020 at 09:41:55PM +0100, Michal Hocko wrote: > > > > On Thu 12-03-20 13:16:02, Minchan Kim wrote: > > > > > On Thu, Mar 12, 2020 at 09:22:48AM +0100, Michal Hocko wrote: > > > > [...] > > > > > > From eca97990372679c097a88164ff4b3d7879b0e127 Mon Sep 17 00:00:00 2001 > > > > > > From: Michal Hocko > > > > > > Date: Thu, 12 Mar 2020 09:04:35 +0100 > > > > > > Subject: [PATCH] mm: do not allow MADV_PAGEOUT for CoW pages > > > > > > > > > > > > Jann has brought up a very interesting point [1]. While shared pages are > > > > > > excluded from MADV_PAGEOUT normally, CoW pages can be easily reclaimed > > > > > > that way. This can lead to all sorts of hard to debug problems. E.g. > > > > > > performance problems outlined by Daniel [2]. There are runtime > > > > > > environments where there is a substantial memory shared among security > > > > > > domains via CoW memory and a easy to reclaim way of that memory, which > > > > > > MADV_{COLD,PAGEOUT} offers, can lead to either performance degradation > > > > > > in for the parent process which might be more privileged or even open > > > > > > side channel attacks. The feasibility of the later is not really clear > > > > > > > > > > I am not sure it's a good idea to mention performance stuff because > > > > > it's rather arguble. You and Johannes already pointed it out when I sbumit > > > > > early draft which had shared page filtering out logic due to performance > > > > > reason. You guys suggested the shared pages has higher chance to be touched > > > > > so that if it's really hot pages, that whould keep in the memory. I agree. > > > > > > > > Yes, the hot memory is likely to be referenced but the point was an > > > > unexpected latency because of the major fault. I have to say that I have > > > > > > I don't understand your point here. If it's likely to be referenced > > > among several processes, it doesn't have the major fault latency. > > > What's your point here? > > > > a) the particular CoW page might be cold enough to be reclaimed and b) > > If it is, that means it's *cold* so it's really worth to be reclaimed. > > > nothing really prevents the MADV_PAGEOUT to be called faster than the > > reference bit being readded. > > Yeb, that's undesirable. I should admit it was not intended when I implemented > PAGEOUT. The thing is page_check_references clears access bit of pte for every > process are sharing the page so that two times MADV_PAGEOUT from a process could > evict the page. That's the really bug. I do not really think this is a bug. This is a side effect of the reclaim process and we do not really want MADV_{PAGEOUT,COLD} behave differently here because then the behavior would be even harder to understand. -- Michal Hocko SUSE Labs