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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 A09E5C433E1 for ; Tue, 11 Aug 2020 21:43:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5E2E920756 for ; Tue, 11 Aug 2020 21:43:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VlfZ+mf9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E2E920756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D68276B0002; Tue, 11 Aug 2020 17:43:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF29D8D0001; Tue, 11 Aug 2020 17:43:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B92CE6B0006; Tue, 11 Aug 2020 17:43:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id 9DBFE6B0002 for ; Tue, 11 Aug 2020 17:43:04 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 044281730876 for ; Tue, 11 Aug 2020 21:43:04 +0000 (UTC) X-FDA: 77139613488.10.honey78_44074ad26fe6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id C971216A4A1 for ; Tue, 11 Aug 2020 21:43:03 +0000 (UTC) X-HE-Tag: honey78_44074ad26fe6 X-Filterd-Recvd-Size: 5837 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Aug 2020 21:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597182182; 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: in-reply-to:in-reply-to:references:references; bh=GOplycSYlrE/8t7FkYQABzHBjonJiVQgHyqp2y7F7QQ=; b=VlfZ+mf9MUGjRGVnkSL3pyK6wIfPXam4qpWrjTRaUybNRPINICbp5qRfBWbwLSwokg07HP Nm4hBJn7J9XVaFxd1Bd6KDBEWr/fqtN7DgyXdN05ZnzBh9XxYOBZkjQv0bBxNDcDKYFejJ Jar/PWOrtN8Pop4hDz7ghBjSwJA/4TY= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-qmgZ6VYaPxCDrp5a863hgg-1; Tue, 11 Aug 2020 17:42:59 -0400 X-MC-Unique: qmgZ6VYaPxCDrp5a863hgg-1 Received: by mail-qk1-f199.google.com with SMTP id d6so101040qkg.6 for ; Tue, 11 Aug 2020 14:42:59 -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=GOplycSYlrE/8t7FkYQABzHBjonJiVQgHyqp2y7F7QQ=; b=GY8/k++wRLissySXcPU5wZkMb9tGSAzRnljAVZrdatB8d6Uu5rpCXcvFrPxCp/PvDk xOpPew8owEbdPRFx4ClVnDRjm3hv3Sk3gEvs9XaOnjBwJVDwZEGN/xFhtkJwIm44OmtC 26CtOB6PX3IhThPvwqIx9Wx+4RgpdIQ43Qs4rOHayv+mTAP9+0BtSJHfkLTgENHbMO+z ioV4c63zRCKuOdLmOYRV+yzquGE4YL0o3MVu1nOi33b4xNWFaBziCLS2d3Yw+HBSVfeY 2o4v2D4CqoSgIhqHypcxdZHXZqegxwdeslKyxreAwpJcQNE89AJHh4fM6WsIWZPqLCWj BJ6A== X-Gm-Message-State: AOAM533rgcwcS/6eJfPw34PIKWyoG0MqmXET+xp6XevC6R9F9oMa61LB 7BT81TlaI1ARi5UEjlFOZaTBsa/7hG/J85yPfLbtq36jc2TtMeSqnkO5FiX6ik/o71kGn+MAYqk qvNEBQjxwhP8= X-Received: by 2002:aed:32e7:: with SMTP id z94mr3339914qtd.17.1597182178812; Tue, 11 Aug 2020 14:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyo8F+uTEcgTbzU3zN2GBs9m/OPQosEA3NnwKTPKN2JruuWVxB92nyAAocuBVSKKliRSGcX9A== X-Received: by 2002:aed:32e7:: with SMTP id z94mr3339893qtd.17.1597182178579; Tue, 11 Aug 2020 14:42:58 -0700 (PDT) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-11-70-53-122-15.dsl.bell.ca. [70.53.122.15]) by smtp.gmail.com with ESMTPSA id d198sm99118qke.129.2020.08.11.14.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:42:57 -0700 (PDT) Date: Tue, 11 Aug 2020 17:42:55 -0400 From: Peter Xu To: Linus Torvalds Cc: Andrea Arcangeli , Linux-MM , Linux Kernel Mailing List , Andrew Morton , Marty Mcfadden , "Maya B . Gokhale" , Jann Horn , Christoph Hellwig , Oleg Nesterov , Kirill Shutemov , Jan Kara Subject: Re: [PATCH v3] mm/gup: Allow real explicit breaking of COW Message-ID: <20200811214255.GE6353@xz-x1> References: <20200811183950.10603-1-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: C971216A4A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, Aug 11, 2020 at 01:46:05PM -0700, Linus Torvalds wrote: > On Tue, Aug 11, 2020 at 1:06 PM Linus Torvalds > wrote: > > > > Maybe trying to reuse the page just isn't worth it? > > Well, the attached patch boots, and hasn't slowed kernel compiles > down. But it may do horrible things due to leaving swap cache pages > and KSM pages to be reaped by the memory scanner, instead of being > reused. > > I wouldn't notice, I have too much memory in this machine anyway. > > It might have positive side effects too, of course. Not waiting for > the page lock in the page fault case could be a big win on some loads. > We do_wp_page() was one of the paths to the page lock that caused the > nasty latency spikes (I'm not sure it was a dominant one, but it was > up there). > > So maybe it is worth running some test loads on. And while this patch > doesn't do it, applying this should mean that you can just revert all > the COW games entirely, and we can remove the should_force_cow_break() > from the GUP paths. > > (Also - if this actually works, we can get rid of reuse_ksm_page(), > this was the only user) I don't know good enough on the reuse refactoring patch (which at least looks functionally correct), but... IMHO we still need the enforced cow logic no matter we refactor the page reuse logic or not, am I right? Example: - Process A & B shares private anonymous page P0 - Process A does READ of get_user_pages() on page P0 - Process A (e.g., another thread of process A, or as long as process A still holds the page P0 somehow) writes to page P0 which triggers cow, so for process A the page P0 is replaced by P1 with identical content Then process A still keeps the reference to page P0 that potentially belongs to process B or others? Thanks, -- Peter Xu