Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp171727pxf; Wed, 17 Mar 2021 19:03:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw077y050tq2Gf5zULfceqYChKkApVt+h6/mxKvORFkVtl5yP90AHi83Fl4syJexP9zGamh X-Received: by 2002:a17:906:b286:: with SMTP id q6mr38772061ejz.422.1616033032003; Wed, 17 Mar 2021 19:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616033031; cv=none; d=google.com; s=arc-20160816; b=fGaSSTkX/WEA7B6Ej+Vue1pX+C4a1Ze//4+XAczNq00o+XTqRk2WWJXelHGrnwUXJe Z/HPJnrjLGuq8X3uGp21dffqpp6SnVpnKGifoCU6RFLUtWrPEhCnGSeJv3VP3D3btv6A bYn3nez8UBJBRkzm6FudSRV4uQh7rv/Tz/ZQRe1IKr4muU/3Y/y4V028AVNIWFBtSJN6 PMX4PTpd6wtUNDHY7ApsmHPL4F+rftm0UcH5+8uJJr4oER4SAsWQg3Ufg2ivZCudKPTx C8d6tsZ3inIullfY7RkW/CEDC296wxtK8nOuoUEBkQWoEv4lsBaybO3I8zvBPi7yyA7h hZ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=v1M50zVO+qfyX8hHQPyP5qHNesgD9s9P1xyKpHxr+O4=; b=0JWvhs4il07MNRj8c7tawlrkGl0cyrugoIRKuY9jSSRwRyiSd8T0gZuK9egHhiKlat cX/kMHiYud1JATarrEf5mSDRboh4bgtMAqa0gJGaSxSaOdCxcofU2TS165jD39hYW0SS BAZAgiYRJlrl17MXg1aISkQfr/O2TI14PU9JuPAdM1vUHu7E81gZkwZU0yk5NlZ6Xg7P QdOUP25rRi4cEobFl8wfFPgH+J3YAtnz5qdU+NFYydyyiR7yNw74j/L5G/jQO3J/5XQM 6B++kRnQptiQbJ53Liz6datJfa/fy0obG6iTTOUD81Q5MKWcBjNX7fsfWkKw/AH1EatW vpzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cbLMc8Ex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci1si451935ejb.3.2021.03.17.19.03.29; Wed, 17 Mar 2021 19:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cbLMc8Ex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbhCRCAT (ORCPT + 99 others); Wed, 17 Mar 2021 22:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbhCRCAF (ORCPT ); Wed, 17 Mar 2021 22:00:05 -0400 Received: from mail-vk1-xa4a.google.com (mail-vk1-xa4a.google.com [IPv6:2607:f8b0:4864:20::a4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A0CC06175F for ; Wed, 17 Mar 2021 19:00:04 -0700 (PDT) Received: by mail-vk1-xa4a.google.com with SMTP id i83so11629922vki.4 for ; Wed, 17 Mar 2021 19:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=v1M50zVO+qfyX8hHQPyP5qHNesgD9s9P1xyKpHxr+O4=; b=cbLMc8ExTKSMcFjJxmr7HW9m23mlVR3fNMnWGPh4+DjYZqiKhZUFQ4qcdVtPpzE/aA 8mzuAfy1Q0Y7qSpp/xGenI6FdRQWsuCmLqLHAF1mcTH7SZsy6c4b5+2jf6nJ4d07Cbfq 4v4LbsEel7zJtXZb2uQdbeUh1djn/FduBWLT8vHUZCzCeLdMhqzuFMfuR2MJROscijad cQ4Qt4Yu9kV7InlNKAAj+USa8pz9YiawXTdgmUDfXxvo13msqrp/Tk04Bqk0ldaoqsYw v7/o8ImE6egm/TTuhWC01bt5tIoIsowp7eUL6ELQhTEBEGO3lNsPjtUir0f1vCIdlEHf AvDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=v1M50zVO+qfyX8hHQPyP5qHNesgD9s9P1xyKpHxr+O4=; b=TA3gKTbQijOFy1zCwtKmg0h5TQ6/Pfv3R7vLzRPqvAqSilb5i6eE6UbGC1po27Q50j 9DIuXKgWeV5raKIJrqSou2FtkpsOYS14YY3ncUUMbmPQiGUBgsYyIKssArZhnUtLW8ZF 4bY8s4yeR3/7YRU3kjHg6J999MSd6NUb51WgcA8v2oQFgpHgNVPkNhQ604oXQNfJXPet PzPl50c4sZwD4DSikPrXDeZfkLtfF1ZjtrZUXxeJPqAB2FkOlrBIW/wwVW3i+NlI4M2b imY0mf6do9NcxvRbNpKLyA3xiVlrZ83HouTtdG4HqE7JBcH/ms0R8S9f7gFnx3P8PqhZ nIVQ== X-Gm-Message-State: AOAM530rOr/DbU8s/iokPUw8lMFCd7HTJ9KmIZ13CBNLGCWI2ifNlHZh xv4YtLH4dKaJaU4SncPijhkjAuJjUhrHow== X-Received: from shakeelb.svl.corp.google.com ([2620:15c:2cd:202:6cf6:3db8:f12:ae7f]) (user=shakeelb job=sendgmr) by 2002:a9f:2142:: with SMTP id 60mr1202881uab.105.1616032804013; Wed, 17 Mar 2021 19:00:04 -0700 (PDT) Date: Wed, 17 Mar 2021 18:59:59 -0700 Message-Id: <20210318015959.2986837-1-shakeelb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH] memcg: set page->private before calling swap_readpage From: Shakeel Butt To: Hugh Dickins , Johannes Weiner Cc: Roman Gushchin , Michal Hocko , Andrew Morton , Minchan Kim , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt , Heiko Carstens Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function swap_readpage() (and other functions it call) extracts swap entry from page->private. However for SWP_SYNCHRONOUS_IO, the kernel skips the swapcache and thus we need to manually set the page->private with the swap entry before calling swap_readpage(). Signed-off-by: Shakeel Butt Reported-by: Heiko Carstens --- Andrew, please squash this into "memcg: charge before adding to swapcache on swapin" patch. mm/memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index aefd158ae1ea..b6f3410b5902 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3324,7 +3324,11 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) workingset_refault(page, shadow); lru_cache_add(page); + + /* To provide entry to swap_readpage() */ + set_page_private(page, entry.val); swap_readpage(page, true); + set_page_private(page, 0); } } else { page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, -- 2.31.0.rc2.261.g7f71774620-goog