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=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 7084FC433E2 for ; Wed, 17 Jun 2020 08:49:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 499852100A for ; Wed, 17 Jun 2020 08:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592383773; bh=yNhKGDhsXCbgK6/RncOTh8CHJUhz9Nrj6Hh/LzygyGg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=M8vLzTAVyjFlXJERdaP88aLuKZFvolDM8SZr2V2SiyJ8aRFLu4NUpSKRGsa69yoyL zVob9WxIwM1B75uVzIjBNHRNmgvzFUsfJzzUTBRAWPBRWZFiYIngSvYj/8Kl1Sg9k8 a7zz0mwHhqEP1Gqorp7SrC8x6YVgpoc37ywTjmt8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbgFQItc (ORCPT ); Wed, 17 Jun 2020 04:49:32 -0400 Received: from mail-ej1-f67.google.com ([209.85.218.67]:33209 "EHLO mail-ej1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbgFQItb (ORCPT ); Wed, 17 Jun 2020 04:49:31 -0400 Received: by mail-ej1-f67.google.com with SMTP id n24so1474433ejd.0; Wed, 17 Jun 2020 01:49:30 -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=nicun5v32ytOl5kIX9jbwdnRFPXaMshWANgztjN0gQE=; b=TDHSa1IvxQM2exPW/6kiHC0/iIIK38Vvsm3w0WV7GSCrx20wrY6E7yXU95JZz/ypUJ NjzZEs3/QGvG7wL+nENE2ezfss4nFSfbrV93QtWu/COcPKRKis1bxRDEeAHAttClFoKi LXqQoCLbItri0CTxFRa4xGT9CpnjTJ/hEeaO8iSyUyDE+dIpdvlWW9DT0sveWcnjpftD WvOvPHhqERoOmpUd2VrilLPfzJNoff7/x1Fc+vNu6q/etnBnsGyfQwas2eZ5ssrYDS+a rVjCFmriDDMVi/9bSE9z9Jl1VlLcqam8fzVX3EqU0YSKCJ/3c2JG+fpSmJSG/XnZZDtc IzSQ== X-Gm-Message-State: AOAM530Ug5VrE0sKyt7PHXvrqTeaP8rmZ8OeUZSKoBTefx6tF8ge+ZR4 N0gUmYRCk2wVhmuBp52a1SE= X-Google-Smtp-Source: ABdhPJwLXbtfdC+OVNbOEj3EtrmJW3BBo2ccpq+fDPSsytr30ENIzevd8Z1hLY9Ogbx4/7A1JClSWA== X-Received: by 2002:a17:906:b845:: with SMTP id ga5mr6509647ejb.300.1592383769411; Wed, 17 Jun 2020 01:49:29 -0700 (PDT) Received: from localhost (ip-37-188-158-19.eurotel.cz. [37.188.158.19]) by smtp.gmail.com with ESMTPSA id a24sm12795625ejc.109.2020.06.17.01.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 01:49:28 -0700 (PDT) Date: Wed, 17 Jun 2020 10:49:27 +0200 From: Michal Hocko To: Andrew Morton , Johannes Weiner Cc: Alex Shi , Joonsoo Kim , Shakeel Butt , Hugh Dickins , "Kirill A. Shutemov" , Roman Gushchin , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH for 5.8] mm: do_swap_page fix up the error code instantiation Message-ID: <20200617084927.GK9499@dhcp22.suse.cz> References: <20200508183105.225460-1-hannes@cmpxchg.org> <20200508183105.225460-17-hannes@cmpxchg.org> <20200611093523.GB20450@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200611093523.GB20450@dhcp22.suse.cz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I hope I haven't missed anything but the patch should be the following. >From acd488c22b4bb2ee42526be8ca67145d5127b014 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Wed, 17 Jun 2020 10:40:47 +0200 Subject: [PATCH] mm: do_swap_page fix up the error code do_swap_page returns error codes from the VM_FAULT* space. try_charge might return -ENOMEM, though, and then do_swap_page simply returns 0 which means a success. We almost never return ENOMEM for GFP_KERNEL single page charge. Except for async OOM handling (oom_disabled v1). So this needs translation to VM_FAULT_OOM otherwise the the page fault path will not notify the userspace and wait for an action. Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation") Signed-off-by: Michal Hocko --- mm/memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index dc7f3543b1fd..d944b7946b27 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3140,8 +3140,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) err = mem_cgroup_charge(page, vma->vm_mm, GFP_KERNEL); ClearPageSwapCache(page); - if (err) + if (err) { + err = VM_FAULT_OOM; goto out_page; + } lru_cache_add(page); swap_readpage(page, true); -- 2.26.2 -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Hocko Subject: [PATCH for 5.8] mm: do_swap_page fix up the error code instantiation Date: Wed, 17 Jun 2020 10:49:27 +0200 Message-ID: <20200617084927.GK9499@dhcp22.suse.cz> References: <20200508183105.225460-1-hannes@cmpxchg.org> <20200508183105.225460-17-hannes@cmpxchg.org> <20200611093523.GB20450@dhcp22.suse.cz> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <20200611093523.GB20450-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Andrew Morton , Johannes Weiner Cc: Alex Shi , Joonsoo Kim , Shakeel Butt , Hugh Dickins , "Kirill A. Shutemov" , Roman Gushchin , linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kernel-team-b10kYP2dOMg@public.gmane.org I hope I haven't missed anything but the patch should be the following. >From acd488c22b4bb2ee42526be8ca67145d5127b014 Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Wed, 17 Jun 2020 10:40:47 +0200 Subject: [PATCH] mm: do_swap_page fix up the error code do_swap_page returns error codes from the VM_FAULT* space. try_charge might return -ENOMEM, though, and then do_swap_page simply returns 0 which means a success. We almost never return ENOMEM for GFP_KERNEL single page charge. Except for async OOM handling (oom_disabled v1). So this needs translation to VM_FAULT_OOM otherwise the the page fault path will not notify the userspace and wait for an action. Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation") Signed-off-by: Michal Hocko --- mm/memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index dc7f3543b1fd..d944b7946b27 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3140,8 +3140,10 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) err = mem_cgroup_charge(page, vma->vm_mm, GFP_KERNEL); ClearPageSwapCache(page); - if (err) + if (err) { + err = VM_FAULT_OOM; goto out_page; + } lru_cache_add(page); swap_readpage(page, true); -- 2.26.2 -- Michal Hocko SUSE Labs