Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp102127imm; Tue, 5 Jun 2018 15:55:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLDWWAsxu/1kYNReGJNsHX7KJtMBGlFYY3YIVtpjnqWmDp7myNskNc19x0njr1Ym9zumA8Q X-Received: by 2002:a62:4fd8:: with SMTP id f85-v6mr502348pfj.77.1528239332725; Tue, 05 Jun 2018 15:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528239332; cv=none; d=google.com; s=arc-20160816; b=c79zXN2/fnMOjBk58KQYX3VtD2rt1XQQN9yc3ocn+ceSPHw9ebP6aN83DVQk3UtCdL sc3uQCyKWdHXOjiTquo+JpgvMYtkSEwPeso+crxag04e0S3oLGr8yklaTD+6BIB9XJPv VQE+K6tC0aHKPr6kM38/S63B7c/DuKTrAaoyNlvXvkofk927mgsvzC10KMWUlKNI24/b 89XmqI4k8tcAOvqJyBnKIetu6x1Y+IyDP0A4Sv42IE1t7NNneq0zvHhTX8fwO7560YR+ P7h6ulFS+ewJ/wAD9zK8fptl8Eos7zWA6SoS7BKRqaarbmQgqAUk5eUJo9a+dUXv0+Qg /WsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=n2TvIele1ZKadrmbtn60p4dRjNhPBKVsN9QsTIqVCec=; b=rEXPZel44BTbtsjfi9jwnplK37jKVTZ0j3/BrcHoXv+qgDheDQT4nPvqaoCgDyS9XA aItx3XWGzVbyUccifuKZV2LYeWFe4wDpptrYVZ1b9pwZvuMf1cmmddimvA6vL1vXP6DR UCfhp4rLk3g0RmoPoIzD/4Kg5esN0eHlFLwscN2HJkLizKYLMuATIwzoQE6OkJTVhLli fmrzaB2b+0v9J16XbvYcuTI1XL4bBzHVFpKUEkS1KJ56xRwQAhDEpJ788wIRhzoV3OvO UmxMJTxypWY/7Kk9MkTJLR5UDqXyjlTRwhWiIGGktxButQC1BP3Fw4mWsoDK7av3ure0 FmZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n1KD/QUL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si4272144pfh.346.2018.06.05.15.55.17; Tue, 05 Jun 2018 15:55:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n1KD/QUL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbeFEWx4 (ORCPT + 99 others); Tue, 5 Jun 2018 18:53:56 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38376 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbeFEWxz (ORCPT ); Tue, 5 Jun 2018 18:53:55 -0400 Received: by mail-pf0-f193.google.com with SMTP id b74-v6so2107354pfl.5 for ; Tue, 05 Jun 2018 15:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=n2TvIele1ZKadrmbtn60p4dRjNhPBKVsN9QsTIqVCec=; b=n1KD/QULqhOTxImLR3CxnyluSD54shceXYSazMPVVjko5YAv0TCM7YUTaSnu9o3xAV Akp1PP92dCpGJA46meLSPwcosG/PU+GlPMYBiGMuY4/o+IuWRA2n6WHL9SeGe3QbzKNz ZNq9fS6bJsVBn6Tn9HV7YD5myK3ZI1QDI4TmkXFzVcVV2XNvnz27w5VmpFhTkTyHMFFO 0o8WGvaGFsl7RhW6f4wfsHkNbMIdoSd382f7WhrhcMQaTRyI8NRu3uAGAoPJ3ikiG9cQ gPWP7vFU52X45MIfzBcGNeG6siSMiepV6LpMeUkTP4wZlNqOguYbHJtfsiLIYrgt64EC ZSxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=n2TvIele1ZKadrmbtn60p4dRjNhPBKVsN9QsTIqVCec=; b=dDgZyPpC1FHSaN5/81kZ/DuZ3KssByjxFfdEIYdLw7vng44bYMGDOQyEngTVlkhj1G cTvLgvWNcKbrOoM96H35cfz+H+IucCeX0JG5D9+b3StWwcCfIC4bQpD/im5VAZ6gyGSQ wk0T+kjWFooZ0z50G40TTErXbo+mQhSEVqql3nhqoJKiOc0xuO2LcHsPj0M+iMhRz8X+ wIAwRBXXYaUf6O/gutzZOalnG8hyOG8R/lLWqJm2GtIWF7n7bbMKGHIcQiqZ55eMpVN9 AM+/MKUGmlCI5WQ92u285KO7CYUk/3esMYKzbD5wejR8NPcbKCTrmSCCFhy1h7MkSDR3 A99A== X-Gm-Message-State: APt69E20zIS4/jIumE7RF7Q7/uTZ4VA15qr4XiDDsGGq729uizPCc2o6 cIVK2VTXrNal9C8nt8HyJf59fl6q X-Received: by 2002:a62:1fd6:: with SMTP id l83-v6mr519285pfj.182.1528239234987; Tue, 05 Jun 2018 15:53:54 -0700 (PDT) Received: from [10.2.101.129] ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id z25-v6sm97894774pfi.171.2018.06.05.15.53.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 15:53:54 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH] mremap: Avoid TLB flushing anonymous pages that are not in swap cache From: Nadav Amit In-Reply-To: <20180605200800.emb3yfdtnpjgmxb7@techsingularity.net> Date: Tue, 5 Jun 2018 15:53:51 -0700 Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , Aaron Lu , Dave Hansen , Linux Kernel Mailing List , linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Message-Id: <4635880A-CC44-4E06-B3DB-597DE6F5B530@gmail.com> References: <20180605171319.uc5jxdkxopio6kg3@techsingularity.net> <20180605200800.emb3yfdtnpjgmxb7@techsingularity.net> To: Mel Gorman X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mel Gorman wrote: > On Tue, Jun 05, 2018 at 12:53:57PM -0700, Nadav Amit wrote: >> While I do not have a specific reservation regarding the logic, I = find the >> current TLB invalidation scheme hard to follow and inconsistent. I = guess >> should_force_flush() can be extended and used more commonly to make = things >> clearer. >>=20 >> To be more specific and to give an example: Can should_force_flush() = be used >> in zap_pte_range() to set the force_flush instead of the current = code? >>=20 >> if (!PageAnon(page)) { >> if (pte_dirty(ptent)) { >> force_flush =3D 1; >> ... >> } >=20 > That check is against !PageAnon pages where it's potentially critical > that the dirty PTE bit be propogated to the page. You could split the > separate the TLB flush from the dirty page setting but it's not the = same > class of problem and without perf data, it's not clear it's = worthwhile. >=20 > Note that I also didn't handle the huge page moving because it's = already > naturally batching a larger range with a lower potential factor of TLB > flushing and has different potential race conditions. I noticed. >=20 > I agree that the TLB handling would benefit from being simplier but = it's > not a simple search/replace job to deal with the different cases that = apply. I understand. It=E2=80=99s not just a matter of performance: having a = consistent implementation can prevent bugs and allow auditing of the invalidation scheme. Anyhow, if I find some free time, I=E2=80=99ll give it a shot.