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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F870C433F5 for ; Tue, 5 Oct 2021 14:40:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4AE0861381 for ; Tue, 5 Oct 2021 14:40:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4AE0861381 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D11686B0071; Tue, 5 Oct 2021 10:40:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC0596B0072; Tue, 5 Oct 2021 10:40:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B885E900002; Tue, 5 Oct 2021 10:40:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id A8E8C6B0071 for ; Tue, 5 Oct 2021 10:40:57 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5DCEA2D388 for ; Tue, 5 Oct 2021 14:40:57 +0000 (UTC) X-FDA: 78662645754.23.8CE829C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id CF2963000CA1 for ; Tue, 5 Oct 2021 14:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633444856; 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=wzU/i4Pg+46qgDCgZNJOC2Q5GF1N36X0X0hspBjPG1E=; b=FYiIgs7Z+G3Ve5OJSO3PgIObxrCaRHaztjKfyCli3/3IzPFF+zchueGUeAiViaCQEFyMrg YAQfr6bEFR/JML55YneTaLR3rys2SGj3+fcNjzuPvOSgcz78Ptmuk70Pa5dg5SMre/IVz9 9hBsc2JOx9Z+dMYRi0C7WFREYr0GXAQ= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-366-J3ftYECYNHiEfeHHLqtRPg-1; Tue, 05 Oct 2021 10:40:54 -0400 X-MC-Unique: J3ftYECYNHiEfeHHLqtRPg-1 Received: by mail-qt1-f198.google.com with SMTP id x6-20020ac81206000000b002a6e46bbd0eso23354201qti.12 for ; Tue, 05 Oct 2021 07:40:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wzU/i4Pg+46qgDCgZNJOC2Q5GF1N36X0X0hspBjPG1E=; b=UjPlAbwA8DULBQO2AzTs8hkCS3L73SAdounxuMPzU7ZYR0ucvi5fY4Hm2e55TcGtT0 ibiZQTVA5FEI02jTMdWtSjr83X21d96/xq9OB9rzdEH6Ft6sSJGvLKtzPKFObCz5ZtS1 4CAl4xmsbWdu9//9FNXRgtire382WrXJDyuJ6bQHUJxt/baK55PNpVNu4Mv1/qWpU+ad Tj/QEfiu3uAgqxEaErFeyzjS5uL4WhHr5TWTs7X8r487IINTBnMCgbtimazfyDXuktxM S7hNZMwYpp139NxLXL5Wub/9scsmHePjHcSkf5NSm+j/xKvH/CIfCAMoUMyuzmGpz1BD LAUA== X-Gm-Message-State: AOAM530hNBa91MVDMFmQVJdev8YMy+ArFTQm3HqOZpjwn7z3lFV+8A/8 cThWM4oxg6FvTqupEvUYN4bXpopBPx0mrv4SewD3Wpu8tCiWcR6BQHP48x2U+N5QUPwnncm0Ie3 n/Xxt1i5v0Ks= X-Received: by 2002:ac8:12:: with SMTP id a18mr19699733qtg.157.1633444853000; Tue, 05 Oct 2021 07:40:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+t2B4lIEFPAbmTXO3075yF8VAAPnvFzGUfF6eQo+6mowEgcIC92iA+n3CUeM44w62NVx2MQ== X-Received: by 2002:ac8:12:: with SMTP id a18mr19699434qtg.157.1633444849664; Tue, 05 Oct 2021 07:40:49 -0700 (PDT) Received: from t490s ([2607:fea8:56a2:9100::bed8]) by smtp.gmail.com with ESMTPSA id m5sm11623756qtk.88.2021.10.05.07.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 07:40:48 -0700 (PDT) Date: Tue, 5 Oct 2021 10:40:47 -0400 From: Peter Xu To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox Subject: Re: [PATCH 3/3] mm/smaps: Simplify shmem handling of pte holes Message-ID: References: <20210917164756.8586-1-peterx@redhat.com> <20210917164756.8586-4-peterx@redhat.com> <4bcf5e1d-cd86-319a-889f-782755955e04@suse.cz> MIME-Version: 1.0 In-Reply-To: <4bcf5e1d-cd86-319a-889f-782755955e04@suse.cz> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CF2963000CA1 X-Stat-Signature: 1eurxmrz4gm5hjhs4up1q136nknkndzp Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FYiIgs7Z; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf08.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-HE-Tag: 1633444856-307894 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, Vlastimil, On Tue, Oct 05, 2021 at 01:15:05PM +0200, Vlastimil Babka wrote: > > Since at it, use the pte_hole() helper rather than dup the page cache lookup. > > pte_hole() is for checking a range and we are calling it for single page, > isnt't that causing larger overhead in the end? There's xarray involved, so > maybe Matthew will know best. Per my understanding, pte_hole() calls xas_load() too at last, just like the old code; it's just that the xas_for_each() of shmem_partial_swap_usage() will only run one iteration, iiuc. > > > Still keep the CONFIG_SHMEM part so the code can be optimized to nop for !SHMEM. > > > > There will be a very slight functional change in smaps_pte_entry(), that for > > !SHMEM we'll return early for pte_none (before checking page==NULL), but that's > > even nicer. > > I don't think this is true, 'unlikely(IS_ENABLED(CONFIG_SHMEM))' will be a > compile-time constant false and shortcut the rest of the 'if' evaluation > thus there will be no page check? Or I misunderstood. The page check I was referring is this one in smaps_pte_entry(): if (!page) return; After the change, with !SHMEM the "else" block will be kept there (unlike the old code as you mentioned it'll be optimized), the smaps_pte_hole_lookup() will be noop so it'll be a direct "return" in that "else", then it should return a bit earlier by not checking "!page" (because in that case pte_none must have page==NULL). Thanks, -- Peter Xu