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 X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8FCAC432C0 for ; Wed, 27 Nov 2019 04:00:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8DD792071E for ; Wed, 27 Nov 2019 04:00:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UA8cQT4s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DD792071E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 22C296B0348; Tue, 26 Nov 2019 23:00:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DD476B0349; Tue, 26 Nov 2019 23:00:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CBB66B034A; Tue, 26 Nov 2019 23:00:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E64D96B0348 for ; Tue, 26 Nov 2019 23:00:03 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 87CBA180AD817 for ; Wed, 27 Nov 2019 04:00:03 +0000 (UTC) X-FDA: 76200704286.14.way19_1d8350e42dc49 X-HE-Tag: way19_1d8350e42dc49 X-Filterd-Recvd-Size: 5281 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Nov 2019 04:00:02 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id k1so10081719pgg.12 for ; Tue, 26 Nov 2019 20:00:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=tPzDWP52pMIW0y9GhlwYX53ztb59aZtQFUquyPdBxfQ=; b=UA8cQT4sPPzDAk/yTmdElxaXyjFhnyRrpJcZyeNQEMYcKEux7hM1c6kIoFx1I+yZuQ wN9kOvOYAVbLuLJgFdUCiA93CNslXHAYkYU3YhHVBar9wTtwlvW4T1is/gL3v2G+qHAe 2dHdKnVESFH0+imrOfB2xhv6HRYVpoAapdyhCtotxrTInZD0aaLaqfC8ShIPlUDnPnm6 hMaAUCobOX6QapYVbPDqtF11Z+brEgBxb6KoiNMrE8ELQja4mIfRiRA5m/wmUn6OuN/V FmfyMc+d8Ryyd2YkcVQKs4IdCof104zjZEnhS5YbupC5ASsJtZhUFtQj7Io1kcfMVCTJ ic+Q== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=tPzDWP52pMIW0y9GhlwYX53ztb59aZtQFUquyPdBxfQ=; b=pSGCkUDny6n6N9ecGLm9wvv25qJa3ykD7011GTZ8mBzG7dWlAH/hrlF0R/3a4UPmm3 /CBziFWqd+d1nAloyodo7FJL+84LldO4ucDugLXgKktTW62E3ysxZoeArQLy1lID+v2i lATLa2ey1xX/ihkuz1lWZz1RRdY5tGrnEsqO9lZoDB6hX/TuKpTTA1q8ryLFmsatyuxh yIEPEKVmUJ+6E/5DKYghNCECzKYQ5EaTHHgDiYDrpDTrUBaoXWCRFwyz6eXe7CVO9yOZ nVwyE/JKBCDdWE4gCKnYWfQ8x2k3HZEmi4644S+lehPRd86RSZPclUGSLl8R/xoOkOK+ eStA== X-Gm-Message-State: APjAAAVj1TUsckwhSC+WDaBTiA1cwBRAcQMT5PX94cPi6QT6KHDuFx3K UQih8/z1dApzIqmWowtXMOHyzg== X-Google-Smtp-Source: APXvYqxNhIt4XZITVq9WPYXV1dSIMA6E+ZrqrkYj3fsimovUhhlRrArdOtsqQOIYfGGnTZLFn9wNGw== X-Received: by 2002:a63:6d4f:: with SMTP id i76mr146712pgc.301.1574827200514; Tue, 26 Nov 2019 20:00:00 -0800 (PST) Received: from [100.112.92.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id m5sm4479407pjl.30.2019.11.26.19.59.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Nov 2019 19:59:59 -0800 (PST) Date: Tue, 26 Nov 2019 19:59:49 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Bharata B Rao cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, linux-mm@kvack.org, paulus@au1.ibm.com, aneesh.kumar@linux.vnet.ibm.com, jglisse@redhat.com, cclaudio@linux.ibm.com, linuxram@us.ibm.com, sukadev@linux.vnet.ibm.com, hch@lst.de, Paul Mackerras , Andrea Arcangeli , Hugh Dickins Subject: Re: [PATCH v11 1/7] mm: ksm: Export ksm_madvise() In-Reply-To: <20191125030631.7716-2-bharata@linux.ibm.com> Message-ID: References: <20191125030631.7716-1-bharata@linux.ibm.com> <20191125030631.7716-2-bharata@linux.ibm.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Mon, 25 Nov 2019, Bharata B Rao wrote: > On PEF-enabled POWER platforms that support running of secure guests, > secure pages of the guest are represented by device private pages > in the host. Such pages needn't participate in KSM merging. This is > achieved by using ksm_madvise() call which need to be exported > since KVM PPC can be a kernel module. > > Signed-off-by: Bharata B Rao > Acked-by: Paul Mackerras > Cc: Andrea Arcangeli > Cc: Hugh Dickins I can say Acked-by: Hugh Dickins to this one. But not to your 2/7 which actually makes use of it: because sadly it needs down_write(&kvm->mm->mmap_sem) for the case when it switches off VM_MERGEABLE in vma->vm_flags. That's frustrating, since I think it's the only operation for which down_read() is not good enough. I have no idea how contended that mmap_sem is likely to be, nor how many to-be-secured pages that vma is likely to contain: you might find it okay simply to go with it down_write throughout, or you might want to start out with it down_read, and only restart with down_write (then perhaps downgrade_write later) when you see VM_MERGEABLE is set. The crash you got (thanks for the link): that will be because your migrate_vma_pages() had already been applied to a page that was already being shared via KSM. But if these secure pages are expected to be few and far between, maybe you'd prefer to keep VM_MERGEABLE, and add per-page checks of some kind into mm/ksm.c, to skip over these surprising hybrids. Hugh > --- > mm/ksm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/ksm.c b/mm/ksm.c > index dbee2eb4dd05..e45b02ad3f0b 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -2478,6 +2478,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, > > return 0; > } > +EXPORT_SYMBOL_GPL(ksm_madvise); > > int __ksm_enter(struct mm_struct *mm) > { > -- > 2.21.0 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 X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5AB3C432C0 for ; Wed, 27 Nov 2019 04:02:30 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25B1B20862 for ; Wed, 27 Nov 2019 04:02:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="UA8cQT4s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25B1B20862 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47N6YH3fMgzDql5 for ; Wed, 27 Nov 2019 15:02:27 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=google.com (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=hughd@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="UA8cQT4s"; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47N6Vh3VRWzDqk8 for ; Wed, 27 Nov 2019 15:00:04 +1100 (AEDT) Received: by mail-pg1-x543.google.com with SMTP id k1so1738083pga.13 for ; Tue, 26 Nov 2019 20:00:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=tPzDWP52pMIW0y9GhlwYX53ztb59aZtQFUquyPdBxfQ=; b=UA8cQT4sPPzDAk/yTmdElxaXyjFhnyRrpJcZyeNQEMYcKEux7hM1c6kIoFx1I+yZuQ wN9kOvOYAVbLuLJgFdUCiA93CNslXHAYkYU3YhHVBar9wTtwlvW4T1is/gL3v2G+qHAe 2dHdKnVESFH0+imrOfB2xhv6HRYVpoAapdyhCtotxrTInZD0aaLaqfC8ShIPlUDnPnm6 hMaAUCobOX6QapYVbPDqtF11Z+brEgBxb6KoiNMrE8ELQja4mIfRiRA5m/wmUn6OuN/V FmfyMc+d8Ryyd2YkcVQKs4IdCof104zjZEnhS5YbupC5ASsJtZhUFtQj7Io1kcfMVCTJ ic+Q== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=tPzDWP52pMIW0y9GhlwYX53ztb59aZtQFUquyPdBxfQ=; b=Bi/a5HnbgTwrESMhrIUeTkZ+77BvVavy/2bIAQPg834ywaQzkJRbZXUtg1cOALQlHa nV9uarKL8nwzUKVMhYp95kTPBEorJJPU10AWYbfwBRY7g7N1FYzHiuugGJRiDZgQMuGh Fn1+qvzkLm64iXFs4pbgQDe65/B3NmIoopLj5TC62Z9ggFMPIC5ecPLLIH6lL480b52Q 48wHz95i7no+UuJOSKbiC1kjHcUEKW2aygT9dyBSYFRyeATgXYGEzEj1V7mHl9GM3hOL /yGRQybfw3Oq+RxWAWJbX4whj7NOQjSn+WpZWVeNHfEH7jBv5Q8UqLgu7k25TyNRKcec QEVA== X-Gm-Message-State: APjAAAVZdiQ8cTmAf4s4R9pX/w3sj66DYdFbd0UHZCD+otF47MBfoZMK 5K2UWGVuPtq02kr+LYQd4SvElQ== X-Google-Smtp-Source: APXvYqxNhIt4XZITVq9WPYXV1dSIMA6E+ZrqrkYj3fsimovUhhlRrArdOtsqQOIYfGGnTZLFn9wNGw== X-Received: by 2002:a63:6d4f:: with SMTP id i76mr146712pgc.301.1574827200514; Tue, 26 Nov 2019 20:00:00 -0800 (PST) Received: from [100.112.92.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id m5sm4479407pjl.30.2019.11.26.19.59.58 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Nov 2019 19:59:59 -0800 (PST) Date: Tue, 26 Nov 2019 19:59:49 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Bharata B Rao Subject: Re: [PATCH v11 1/7] mm: ksm: Export ksm_madvise() In-Reply-To: <20191125030631.7716-2-bharata@linux.ibm.com> Message-ID: References: <20191125030631.7716-1-bharata@linux.ibm.com> <20191125030631.7716-2-bharata@linux.ibm.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrea Arcangeli , Hugh Dickins , linuxram@us.ibm.com, cclaudio@linux.ibm.com, kvm-ppc@vger.kernel.org, linux-mm@kvack.org, jglisse@redhat.com, aneesh.kumar@linux.vnet.ibm.com, paulus@au1.ibm.com, sukadev@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, hch@lst.de Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, 25 Nov 2019, Bharata B Rao wrote: > On PEF-enabled POWER platforms that support running of secure guests, > secure pages of the guest are represented by device private pages > in the host. Such pages needn't participate in KSM merging. This is > achieved by using ksm_madvise() call which need to be exported > since KVM PPC can be a kernel module. > > Signed-off-by: Bharata B Rao > Acked-by: Paul Mackerras > Cc: Andrea Arcangeli > Cc: Hugh Dickins I can say Acked-by: Hugh Dickins to this one. But not to your 2/7 which actually makes use of it: because sadly it needs down_write(&kvm->mm->mmap_sem) for the case when it switches off VM_MERGEABLE in vma->vm_flags. That's frustrating, since I think it's the only operation for which down_read() is not good enough. I have no idea how contended that mmap_sem is likely to be, nor how many to-be-secured pages that vma is likely to contain: you might find it okay simply to go with it down_write throughout, or you might want to start out with it down_read, and only restart with down_write (then perhaps downgrade_write later) when you see VM_MERGEABLE is set. The crash you got (thanks for the link): that will be because your migrate_vma_pages() had already been applied to a page that was already being shared via KSM. But if these secure pages are expected to be few and far between, maybe you'd prefer to keep VM_MERGEABLE, and add per-page checks of some kind into mm/ksm.c, to skip over these surprising hybrids. Hugh > --- > mm/ksm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/ksm.c b/mm/ksm.c > index dbee2eb4dd05..e45b02ad3f0b 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -2478,6 +2478,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, > > return 0; > } > +EXPORT_SYMBOL_GPL(ksm_madvise); > > int __ksm_enter(struct mm_struct *mm) > { > -- > 2.21.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hugh Dickins Date: Wed, 27 Nov 2019 03:59:49 +0000 Subject: Re: [PATCH v11 1/7] mm: ksm: Export ksm_madvise() Message-Id: List-Id: References: <20191125030631.7716-1-bharata@linux.ibm.com> <20191125030631.7716-2-bharata@linux.ibm.com> In-Reply-To: <20191125030631.7716-2-bharata@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Bharata B Rao Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, linux-mm@kvack.org, paulus@au1.ibm.com, aneesh.kumar@linux.vnet.ibm.com, jglisse@redhat.com, cclaudio@linux.ibm.com, linuxram@us.ibm.com, sukadev@linux.vnet.ibm.com, hch@lst.de, Paul Mackerras , Andrea Arcangeli , Hugh Dickins On Mon, 25 Nov 2019, Bharata B Rao wrote: > On PEF-enabled POWER platforms that support running of secure guests, > secure pages of the guest are represented by device private pages > in the host. Such pages needn't participate in KSM merging. This is > achieved by using ksm_madvise() call which need to be exported > since KVM PPC can be a kernel module. > > Signed-off-by: Bharata B Rao > Acked-by: Paul Mackerras > Cc: Andrea Arcangeli > Cc: Hugh Dickins I can say Acked-by: Hugh Dickins to this one. But not to your 2/7 which actually makes use of it: because sadly it needs down_write(&kvm->mm->mmap_sem) for the case when it switches off VM_MERGEABLE in vma->vm_flags. That's frustrating, since I think it's the only operation for which down_read() is not good enough. I have no idea how contended that mmap_sem is likely to be, nor how many to-be-secured pages that vma is likely to contain: you might find it okay simply to go with it down_write throughout, or you might want to start out with it down_read, and only restart with down_write (then perhaps downgrade_write later) when you see VM_MERGEABLE is set. The crash you got (thanks for the link): that will be because your migrate_vma_pages() had already been applied to a page that was already being shared via KSM. But if these secure pages are expected to be few and far between, maybe you'd prefer to keep VM_MERGEABLE, and add per-page checks of some kind into mm/ksm.c, to skip over these surprising hybrids. Hugh > --- > mm/ksm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/ksm.c b/mm/ksm.c > index dbee2eb4dd05..e45b02ad3f0b 100644 > --- a/mm/ksm.c > +++ b/mm/ksm.c > @@ -2478,6 +2478,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, > > return 0; > } > +EXPORT_SYMBOL_GPL(ksm_madvise); > > int __ksm_enter(struct mm_struct *mm) > { > -- > 2.21.0