From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F784C43334 for ; Fri, 1 Jul 2022 13:19:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EE3E6B0071; Fri, 1 Jul 2022 09:19:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89EF66B0073; Fri, 1 Jul 2022 09:19:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78D1E6B0074; Fri, 1 Jul 2022 09:19:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 69FCE6B0071 for ; Fri, 1 Jul 2022 09:19:39 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 3E26D60D2B for ; Fri, 1 Jul 2022 13:19:39 +0000 (UTC) X-FDA: 79638588078.02.234B08C Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf24.hostedemail.com (Postfix) with ESMTP id 3C77818004F for ; Fri, 1 Jul 2022 13:19:38 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id B11C01FED2; Fri, 1 Jul 2022 13:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1656681576; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xFgoHlyRa7LHDHxJ/dQcYb8z363BN8ijGLLytPfITt4=; b=qlUZohiu44BSWswbAw5H6MLyMuGchSMRiwXroekPENBEzT1W1745fSk07Kgg+BoK7DIOEH gyrTJuxqaZVllCRs0XWu7Ppewzgjsx0YiO+Xd6dkKt2dUjz9m0K3J8VnjKGv79GEJxnNP+ A2YQ8WrpHsKMGRK4zAHmwOqqCWW+NJQ= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C4E3B2C141; Fri, 1 Jul 2022 13:19:35 +0000 (UTC) Date: Fri, 1 Jul 2022 15:19:35 +0200 From: Michal Hocko To: David Hildenbrand Cc: cgel.zte@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, vbabka@suse.cz, minchan@kernel.org, oleksandr@redhat.com, xu xin , Jann Horn , Andrew Morton Subject: Re: [PATCH linux-next] mm/madvise: allow KSM hints for process_madvise Message-ID: References: <20220701084323.1261361-1-xu.xin16@zte.com.cn> <93e1e19a-deff-2dad-0b3c-ef411309ec58@redhat.com> <203548a6-cf70-30ce-6756-f6c909e7ef21@redhat.com> <54b67d6b-f600-1b9b-3d3f-e91b13d04c91@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54b67d6b-f600-1b9b-3d3f-e91b13d04c91@redhat.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656681578; a=rsa-sha256; cv=none; b=Y9IrrOjds60CWEIi0Pg01yyVjw1qBe1H9fw/GcnNcp3AaMcLXTqprCQ8V8XXUXqM4Hqzk6 7IXToRDSEwbniERTUceOS7WIPNUMyDXzrgdhavgTerypodXeXnv2Qar7Un/BoUUZVvj9nw /5vz29Rs8yTPeNNRS5wRUr7NV7OP7Oo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=qlUZohiu; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf24.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656681578; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xFgoHlyRa7LHDHxJ/dQcYb8z363BN8ijGLLytPfITt4=; b=ycht4CTn16ur0L96A0BO08PO3bSlOLzFxQRdoFLP0mjvwHz7MpBQFG/sdFd2UvnlrBFks+ 6KzDWbl7HrA8YFKz0/UhfiQ6DT/KPvo5CTHqwqxgkUeOjuKuWMrhZuld0kMJPVujGbNb9i pFjJMf23lPlLWXIEkjhbCT9/qYTKXK0= X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3C77818004F Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=qlUZohiu; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf24.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspam-User: X-Stat-Signature: ya7cgw3ozo653yzesrmedthjt143xrds X-HE-Tag: 1656681578-224039 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri 01-07-22 14:39:24, David Hildenbrand wrote: > > I am not sure about exact details of the KSM implementation but if that > > is not a desirable behavior then it should be handled on the KSM level. > > The very sam thing can easily happen in a multithreaded (or in general > > multi-process with shared mm) environment as well. > > I don't quite get what you mean. I meant to say that if KSM needs to be aware of a special CoW semantic then it should be handled on the KSM layer regardless whether the KSM has been set by the process itself or any other process that has acccess to the MM. process_madvise is just another way to access a remote MM other than sharing the full MM. [...] > > Are you saying that any remote handling of the KSM has to deal with a > > pre-existing semantic as well? Are we aware of any existing application > > that really uses MADV_UNMERGEABLE in a hope to disable KSM for any of > > its sensitive memory ranges? My understanding is that this is simply a > > on/off knob and a remote way to do the same is in line with the existing > > API. > > "its sensitive memory ranges" that's exactly what I am concerned of. > There should be a toggle, and existing applciations will not be using it. The thing is that most applications (are there any?) do not actively say that something is not KSM safe, right? They expect they opt in where it makes sense. So my question is, whether any remote way to opt in for KSM has to redefine the existing semantic or the same should be achieved by a sufficient privileges? The former would have really hard times to be applicable to the very likely first hand usecase - unmodifiable binaries... > > To be completely honest I do not really buy an argument that this might > > break something much more than the original application can do already. > > How can you get a shared zeropage in a private mapping after a previous > write if not via KSM? I was not referring to KSM specifically here. My recollection is that PTRACE_MODE_READ_FSCREDS is quite powerful already. -- Michal Hocko SUSE Labs