Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2536678rwr; Fri, 21 Apr 2023 10:08:44 -0700 (PDT) X-Google-Smtp-Source: AKy350br2QVQKdTJJ3Jf2evRcqjxj0b3dWz/PgftmBgukrhuHcdkXsCkedmhnlUEykTuWVMLUGJu X-Received: by 2002:a17:90a:1a17:b0:247:9e56:d895 with SMTP id 23-20020a17090a1a1700b002479e56d895mr5369595pjk.1.1682096924349; Fri, 21 Apr 2023 10:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682096924; cv=none; d=google.com; s=arc-20160816; b=dnGxXUsMzUomaM6/9npnEk4YA2t80mE698MVc+SXuJLDVp3YhR9U20kzeI1On5ueR7 cQynTdBr/PuJd2WuDAWDWHCsE/elExV2vJf24cLgDf7C1YYPfnIrIUHZ3k4aVXKsLP0F Z76gdRl3x2qas8yvD4vGTIJy6m1kYc/hXPgib7lVD1xVekD0xEL+uV8uBGxjPM2CsYe1 EoFcsrEn3owPhQF8FeJiauyx70VKPyPgUEJZpxitVQ+L5v1DOIaigkCOJXwnncJ9jQeD U/W9BEjxkbpGr1CXOW/NRZNApyGoFUwNAP/Zgv2zlr2ghFtEbUFLWIASDkEqbB54BRKG mYrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:content-language:references:cc:to:user-agent :mime-version:date:message-id:dkim-signature; bh=g7lG6rnmj15jmZA/ctqiBLvmqWQqJhRL1h9zNRtPjNc=; b=o7/sc0r0XAdbiCMY5ShWK+B3C6tFwdp77AnY1N9Cqbtn+VUN9c8qIbsohKGXBPOKQG g80yigbqLgV+QTiQIkcVe6Ckv3g1ii/I8RR6aQDt1AfRPU+DSZLjUGprt271+nAxDGwO JrgTvoErqiO0LfV3jvrhmHisjm44fXVE2TRfcc2BusENDjf2f4XNkCt9jRrD1n1X3RDZ B0YU2CXJkF70vsTG6vZ3tCYwX++CYQ7aNMOL9IWcvv5HwuIbuXPqzKtkDqE4IqkYU4K+ Ti3TNf2O1nEfYHDSNuQjQN3WCWVzEOZfxp4Vi//QDSSOR0duC5hPuu4MMRIyB0VVlFRm QOlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gFzh9RAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm5-20020a17090afa0500b0024728b38038si7572685pjb.72.2023.04.21.10.08.33; Fri, 21 Apr 2023 10:08:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gFzh9RAc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232943AbjDURID (ORCPT + 99 others); Fri, 21 Apr 2023 13:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232589AbjDURH5 (ORCPT ); Fri, 21 Apr 2023 13:07:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA5B14454 for ; Fri, 21 Apr 2023 10:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682096821; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g7lG6rnmj15jmZA/ctqiBLvmqWQqJhRL1h9zNRtPjNc=; b=gFzh9RAc/MQGsmqu5leBq8PrETrWyL/I7ZTEiViN0IgeUxFZBoXPt6iabMz3fOxI+rbyJy Bc2eKFME+yD/JMM4Ah47YVqSMrCqgml35dzCI7+GrzUZFC6E2Ne9MnvIMhI3PeigtZEmRz q5J9cNvKmBx14jmL9ERb1QKHBNyZuic= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-4EUZO_INP7uN0dkrxvZODg-1; Fri, 21 Apr 2023 12:52:17 -0400 X-MC-Unique: 4EUZO_INP7uN0dkrxvZODg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f1793d6363so7031035e9.1 for ; Fri, 21 Apr 2023 09:52:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682095936; x=1684687936; h=content-transfer-encoding:in-reply-to:subject:organization:from :content-language:references:cc:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g7lG6rnmj15jmZA/ctqiBLvmqWQqJhRL1h9zNRtPjNc=; b=eEaQ/gUaDSeJi2JawLgxBln3+0VZ7jiiuxnRLVZ3ggkznvcQOIkdyWbNTgW/OaQKZ4 58/uVuVLkD+tlP0uKNh13TbLYfZr3t37mh3g+LyTZZFo6ncr4azTa9u0uUnvsiDaiw7C Yee1a4KQ0aYUYQuPux6iyra0qRBdYDCanxLSBULZ/6psinw0/TxNO9yTX8QM2W4bD9Eb 1eLG4j3KVehP6lqwAWv1kg54KBZrqLTq9RI6tDT6niO2X+Jz5Lyu4nFQByQJ4mIORzKA LZAqeXMailbUh+JCoXUCpQvPkIyN80Op4HJfcSgNPoibRLxy+aG85Idlpy+ZDQGwopMW TSdg== X-Gm-Message-State: AAQBX9cvLU38BvQppwCFWRppBSgdLhO465AqopPeahIdaPTpKDXoVDSD 8wkkeKeInbXJUGDu2jiClp0x/W/x/N/o2kBVpFNdU7K2VSDc5WfwL9a7BRwFraGGDM5e7THAHuD TMLXiMo//xE7hutjov+NLWIVV X-Received: by 2002:a1c:7c12:0:b0:3ed:b048:73f4 with SMTP id x18-20020a1c7c12000000b003edb04873f4mr2736906wmc.5.1682095936531; Fri, 21 Apr 2023 09:52:16 -0700 (PDT) X-Received: by 2002:a1c:7c12:0:b0:3ed:b048:73f4 with SMTP id x18-20020a1c7c12000000b003edb04873f4mr2736885wmc.5.1682095936116; Fri, 21 Apr 2023 09:52:16 -0700 (PDT) Received: from ?IPV6:2003:cb:c717:6a00:e38f:c852:dc11:9146? (p200300cbc7176a00e38fc852dc119146.dip0.t-ipconnect.de. [2003:cb:c717:6a00:e38f:c852:dc11:9146]) by smtp.gmail.com with ESMTPSA id w9-20020a05600c474900b003f17e37ce60sm8676540wmo.47.2023.04.21.09.52.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Apr 2023 09:52:15 -0700 (PDT) Message-ID: <14d89518-0c11-7bfb-0c72-329a834ba1a1@redhat.com> Date: Fri, 21 Apr 2023 18:52:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: Stefan Roesch Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-kselftest@vger.kernel.org, Andrew Morton , Rik van Riel , Johannes Weiner , Michal Hocko , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Sven Schnelle , Shuah Khan References: <20230418051342.1919757-1-shr@devkernel.io> <20230418152849.505124-1-david@redhat.com> <20230418152849.505124-4-david@redhat.com> Content-Language: en-US From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1 3/3] mm/ksm: move disabling KSM from s390/gmap code to KSM code In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] >> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c >> index 0949811761e6..dfe905c7bd8e 100644 >> --- a/arch/s390/mm/gmap.c >> +++ b/arch/s390/mm/gmap.c >> @@ -2585,30 +2585,12 @@ EXPORT_SYMBOL_GPL(s390_enable_sie); >> >> int gmap_mark_unmergeable(void) >> { >> - struct mm_struct *mm = current->mm; >> - struct vm_area_struct *vma; >> - unsigned long vm_flags; >> - int ret; >> - VMA_ITERATOR(vmi, mm, 0); >> - >> /* >> * Make sure to disable KSM (if enabled for the whole process or >> * individual VMAs). Note that nothing currently hinders user space >> * from re-enabling it. >> */ >> - clear_bit(MMF_VM_MERGE_ANY, &mm->flags); >> - >> - for_each_vma(vmi, vma) { >> - /* Copy vm_flags to avoid partial modifications in ksm_madvise */ >> - vm_flags = vma->vm_flags; >> - ret = ksm_madvise(vma, vma->vm_start, vma->vm_end, >> - MADV_UNMERGEABLE, &vm_flags); >> - if (ret) >> - return ret; >> - vm_flags_reset(vma, vm_flags); >> - } >> - mm->def_flags &= ~VM_MERGEABLE; >> > Hi Stefan, > This clears the def_flags struct member, however, in ksm_disable() we > clear the __flags struct member. Is this a problem? The patch description contains a comment regarding def_flags: "The existing "mm->def_flags &= ~VM_MERGEABLE;" was essentially a NOP and can be dropped, because def_flags should never include VM_MERGEABLE." We keep clearing the MADV_UNMERGEABLE flag from MADV_UNMERGEABLE. In the old code, ksm_madvise() would have cleared it from local vm_flags and vm_flags_reset() would have modified vma->vm_flags. Now we clear it directly via vm_flags_clear(vma, VM_MERGEABLE); Long story short, the mm->def_flags code as wrong and most probably copied from thp_split_mm() where we do: mm->def_flags |= VM_NOHUGEPAGE; Which makes more sense. Thanks! -- Thanks, David / dhildenb