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 5213AC433FE for ; Thu, 20 Oct 2022 10:05:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83A746B0071; Thu, 20 Oct 2022 06:05:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EA8D6B0073; Thu, 20 Oct 2022 06:05:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B4778E0001; Thu, 20 Oct 2022 06:05:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 578BE6B0071 for ; Thu, 20 Oct 2022 06:05:36 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 202FBC0571 for ; Thu, 20 Oct 2022 10:05:36 +0000 (UTC) X-FDA: 80040895872.05.E0D910A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 18867140036 for ; Thu, 20 Oct 2022 10:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666260334; 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=b6yK6XC2fpvM5GYufymBVihPn45YwUGwSfARH9fFd4M=; b=Y+jcC3NhgyxsKN3cmKlZr7ZWBxRQEQCu08y0r1Kg55AlbRi8IR8+F87QDBGG6id34ouqFi ebW3hOTgnzpQVcvoiL+pQP7H8jB3PtAm3Ns92Ng9f5w7RHca+IkOujpeovPWHbWInIT1CD NyOfSi3SrpLUpu4nkt5PTXMAco7CZrg= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-496-jyr1h3hBNN-VGqVd9xaK_g-1; Thu, 20 Oct 2022 06:05:33 -0400 X-MC-Unique: jyr1h3hBNN-VGqVd9xaK_g-1 Received: by mail-wm1-f69.google.com with SMTP id v191-20020a1cacc8000000b003bdf7b78dccso12142597wme.3 for ; Thu, 20 Oct 2022 03:05:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b6yK6XC2fpvM5GYufymBVihPn45YwUGwSfARH9fFd4M=; b=AVE2H5iqO2yFCYXUJvah6c7hasV/9P2DVPHP16MTQsTJbhrkARp5zDu1N7Zw+SJqgT DgjIvDVgW8s5Zt6OFbdSucVmgXk+icJCJS1oZMyRgfY3zqh8+yw40ZAmPCWVETjWBbWH 6KS9zK8N2zhgcZngnojVUI9/wbvG3oPY0unMSNPpF8e7VKeRfzaBdYBViqGg54pZ1UCf EUzCRLlfkASKAKh5xJCJJzCZ05FhId1/dg4ln4sJjO5diPDCsnICFLoWQgRKYYpYnUKT 7wvmVf1DT45v5hr9W20dsNVt8N1q1H19lWNdhsWeBTKdVQ2A5yqb0Tb8yfc5WR1DHJ8l CEeQ== X-Gm-Message-State: ACrzQf2Qy8RBE0FjZ4S5/ZWboSiTGG8oOJjeKnARFtuZ7yWUPB7nh2Xq ywLlK3OmRTLAN3jxK1yqoWEJp544Uu9ZL7qDn9qp6pqQ39X83DTUw9gVL+8h4sAfbPHnJFsdede B69pTNdbAWDM= X-Received: by 2002:adf:dc4b:0:b0:230:5fe6:69d2 with SMTP id m11-20020adfdc4b000000b002305fe669d2mr7935520wrj.469.1666260331794; Thu, 20 Oct 2022 03:05:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4g+BdVVhP/DCqSzgafKraJ4+5xJgtnKBLUIP0W7QYfpF3Ib4HNHfxW8nd9OyuxmutH2d9vcA== X-Received: by 2002:adf:dc4b:0:b0:230:5fe6:69d2 with SMTP id m11-20020adfdc4b000000b002305fe669d2mr7935479wrj.469.1666260331411; Thu, 20 Oct 2022 03:05:31 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:b100:1443:78d5:341f:c97a? (p200300cbc708b100144378d5341fc97a.dip0.t-ipconnect.de. [2003:cb:c708:b100:1443:78d5:341f:c97a]) by smtp.gmail.com with ESMTPSA id v10-20020a5d4a4a000000b00236492b3315sm413315wrs.104.2022.10.20.03.05.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Oct 2022 03:05:30 -0700 (PDT) Message-ID: <95c44cc0-31db-88cf-7296-7c18a1e7f42a@redhat.com> Date: Thu, 20 Oct 2022 12:05:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Andrew Morton , Shuah Khan , Hugh Dickins , Vlastimil Babka , Andrea Arcangeli , "Matthew Wilcox (Oracle)" , Jason Gunthorpe , John Hubbard References: <20220930141931.174362-1-david@redhat.com> <20220930141931.174362-5-david@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1 4/7] mm/ksm: fix KSM COW breaking with userfaultfd-wp via FAULT_FLAG_UNSHARE In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666260335; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b6yK6XC2fpvM5GYufymBVihPn45YwUGwSfARH9fFd4M=; b=5F6YLUqo+IkemJ3TWYje+uKeeln2xQM1Bc5eCwPv5vsGh4I8oP/wJ+T8EJJAHSonRLj5Xh Koqi6SFsndIbShnbSnyAA3P5Gs7egL7sf32Cu6jd7q1dSuzjkL6cAi4R0R6AmHdo0f94Im lBo6NcDIsn0gFPXpELSfePY6VclyGYY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y+jcC3Nh; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666260335; a=rsa-sha256; cv=none; b=bmyv0554DpToLrgMhD25PBAiF/GA0qOXkjrNd/DO6qAG/OXO8cxo87ND6KjqZ1NMR1RW/U FHr5lHUeU3E2InEMdZwQC6b/oIl/5hdExA/McRoJXB9yKAmgEEuqr8JpILl1jDie87jdOB 6eABXnw7GM7y8JqVj4S3+622LfuC5Is= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 18867140036 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y+jcC3Nh; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: xnwzmywwcx1m8zt74fob5rbke6e36h5e X-HE-Tag: 1666260334-791231 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: Hi Peter, sorry for replying so late, I only managed now to get back to this patch set. >> Yes, I can give it a try. What I dislike about ksm_test is that it's a >> mixture of benchmarks and test cases that have to explicitly triggered by >> parameters. It's not a simple "run all available test cases" tests as we >> know it. So maybe something separate (or having it as part of the uffd >> tests) makes more sense. > > We can add an entry into run_vmtests.sh. That's also what current ksm_test > does. Right, but I kind-of don't like that way at all and would much rather do it cleaner... > > Yes adding into uffd test would work too, but I do have a plan that we > should move functional tests out of userfaultfd.c, leaving that with the > stress test only. Not really a big deal, though. ... similar to what you want to do with userfaultfd.c So maybe I'll just add a new test for ksm functional tests. > >> >>> >>>> >>>> Consequently, we will no longer trigger a fake write fault and break COW >>>> without any such side-effects. >>>> >>>> This is primarily a fix for KSM+userfaultfd-wp, however, the fake write >>>> fault was always questionable. As this fix is not easy to backport and it's >>>> not very critical, let's not cc stable. >>> >>> A patch to cc most of the stable would probably need to still go with the >>> old write approach but attaching ALLOW_RETRY. But I agree maybe that may >>> not need to bother, or a report should have arrived earlier.. The unshare >>> approach looks much cleaner indeed. >> >> A fix without FAULT_FLAG_UNSHARE is not straight forward. We really don't >> want to notify user space about write events here (because there is none). >> And there is no way around the uffd handling in WP code without that. >> >> FAULT_FLAG_ALLOW_RETRY would rely on userfaultfd triggering and having to >> resolve the WP event. > > Right it'll be very much a false positive, but the userspace should be fine > with it e.g. for live snapshot we need to copy page earlier; it still won't > stop the process from running along the way. But I agree that's not ideal. At least the test case at hand will wait until infinitely, because there is no handler that would allow break_cow to make progress (well, we don't expect write events in the test :) ). Anyhow, I don't think messing with that for stable kernels is worth the pain / complexity / possible issues. -- Thanks, David / dhildenb