From patchwork Thu Mar 18 01:59:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 12147199 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 5C154C433E0 for ; Thu, 18 Mar 2021 02:00:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B15E964E99 for ; Thu, 18 Mar 2021 02:00:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B15E964E99 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB7156B006C; Wed, 17 Mar 2021 22:00:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C675E6B0071; Wed, 17 Mar 2021 22:00:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B08366B0072; Wed, 17 Mar 2021 22:00:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 961CB6B006C for ; Wed, 17 Mar 2021 22:00:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5A37F5DFE for ; Thu, 18 Mar 2021 02:00:05 +0000 (UTC) X-FDA: 77931339570.29.43BE49A Received: from mail-vk1-f201.google.com (mail-vk1-f201.google.com [209.85.221.201]) by imf21.hostedemail.com (Postfix) with ESMTP id F2028E0011CE for ; Thu, 18 Mar 2021 02:00:04 +0000 (UTC) Received: by mail-vk1-f201.google.com with SMTP id i65so11660208vkg.19 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=CNC0MSRwAwMJYIUsDj3Cte8ULvLNpq0e0ZiTli7r2NQDideG0Cz11QUcv+9n6BNNFG SbBr2oysLHBIt/pW2kkKXRAdpOsrKtNWJbWZw9uA4igdrItTDRyvSJ6RTOKtn41zBD6l ErSqjeqXwCqh0VPfQgSg7FQfmez0gXWDjaaNOIQDthiMgfobXMIlSEpd3S2D3DqPOdg8 iFzEWfy1PfISy8dPOR2dPqFhRjNSnpsILcOqILyKXteTiDp2kdTtYRkECArnmZeawAZ3 vkTgdwFBICvHNLKSQa7I9J2ybM+HcaffKGhMMJ8+hxWFPJWdsCA2kXd9kNpCp/ybbYja 0B6Q== X-Gm-Message-State: AOAM533dptyDBn0dvdt9GkWOkS0EGrFCxnu1lAaG0rqQYar4VvRcSH/B RI8crhpwUBxZlKPfgr/tzllPPG7z2y5mWg== X-Google-Smtp-Source: ABdhPJw8W0/x+H/Lj+3kOZGld4iiR5NSu7ISSwZyTycTarKtlprPwF1Pzu5TDYhgohhf4nqt8oNMwjVJjI1ryA== 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 X-Stat-Signature: 8dhjyrpcmyg1sagf4t3e9hxewjb6odia X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F2028E0011CE Received-SPF: none (flex--shakeelb.bounces.google.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from="<3JLRSYAgKCN8TIBLFFMCHPPHMF.DPNMJOVY-NNLWBDL.PSH@flex--shakeelb.bounces.google.com>"; helo=mail-vk1-f201.google.com; client-ip=209.85.221.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616032804-745141 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001440, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Tested-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,