From patchwork Wed May 27 10:33:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hui yang X-Patchwork-Id: 11572569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA94B912 for ; Wed, 27 May 2020 10:33:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 768C220EDD for ; Wed, 27 May 2020 10:33:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X7tx2ceX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 768C220EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A362F800C2; Wed, 27 May 2020 06:33:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E61E80010; Wed, 27 May 2020 06:33:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FBE9800C2; Wed, 27 May 2020 06:33:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 7735480010 for ; Wed, 27 May 2020 06:33:46 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2550D8245578 for ; Wed, 27 May 2020 10:33:46 +0000 (UTC) X-FDA: 76862138052.25.stop10_51020ea26d51 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 00A981804E3B5 for ; Wed, 27 May 2020 10:33:45 +0000 (UTC) X-Spam-Summary: 2,0,0,34c7f6850d37fc05,d41d8cd98f00b204,yanghui.def@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1540:1711:1714:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3351:3867:3868:3870:3872:4321:5007:6261:6653:7514:7576:7901:8957:9413:10004:11026:11473:11658:11914:12043:12296:12297:12517:12519:12555:12679:12895:12986:13069:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30012:30054,0,RBL:209.85.215.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: stop10_51020ea26d51 X-Filterd-Recvd-Size: 3414 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 May 2020 10:33:45 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id f21so8589368pgg.12 for ; Wed, 27 May 2020 03:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=zNilonNJF5WCcX4OXqzuDKy3oPHseEyv91M215WHYRM=; b=X7tx2ceXjkZCB+dYZfULu4NjB0GTgSXoNYgIBTQ8YrF6RpFSgqoZfzp+NwOzAxr14l xhkEY2zn2UhnCYCWvPUNNFzhQpOMYM8d1NPUmbR6VTui+RiheAESLAn2KtndfqoRY3e8 9lIr90FTvALCUWugO1f5IGjY0VW4/EkIsA4OdG2oGxI1r5q10vNRxKYkvrfxfItqnIvA Yiew0cFii8cjATVcRA+v7au13ulOei+uKUi9rASa8MKkck8FtaUjp9tlEDLHhJnc7HMu 7OrwwAFAoIZs8+SFRzQWYTueaOrcuOi1tBcZBdoXT0UN/MdJJschJXfJ0p6SBTNX1yW6 7qNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zNilonNJF5WCcX4OXqzuDKy3oPHseEyv91M215WHYRM=; b=DrN6W7fe6ztnIfMpVRlZoYiJ/e0t6HfDTMyWX91aQkOQ23SaGmxBq7raR1M0Wot5Q/ znJEt9L2wct10lXbI/eLudaxLARWYjRfyzvSo2/7z8LOdXO3+l/UIBBjB/9zCyeHedFH 73Bek7V2tkx9ESNLDcn2F2Orpt4fAZ9v16ZxuanNVqCCutOvfJCQKCzpVDRivxkrHOoe 15JgCoq9gxAgMT+rXJnj+GPUJtLjMPbqrbR1ZnQro3U8KxUZIJlNDINA6OXnXtVwmLMg 3ZGWwwKFKdo+Zo8y82zsyY7z5QGWwijK1ornqvqRdYBUQIuNzq6Ubn4cyjlp/KcsALUW sA6A== X-Gm-Message-State: AOAM533b0G4o/9fX4OUTELNw+eSKKSoFk7CCD+aiBVBIuM7PjuNMAr02 onwoKFd5SIkgVtjaEPydiJ5arm/oZEA= X-Google-Smtp-Source: ABdhPJxbeNMx3F2D5Rcj90inhRbQ7geoJ1NXYbSsoL8ScZbIjCmN9MMMX3HkB5upGLdxQrqS+w+UXA== X-Received: by 2002:a63:504f:: with SMTP id q15mr3388312pgl.423.1590575624623; Wed, 27 May 2020 03:33:44 -0700 (PDT) Received: from ubuntu.localdomain ([118.193.245.26]) by smtp.gmail.com with ESMTPSA id f11sm1812528pfa.32.2020.05.27.03.33.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2020 03:33:43 -0700 (PDT) From: hui yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, YangHui Subject: [PATCH 26/26] mm page_fault: Reduce code complexity Date: Wed, 27 May 2020 18:33:30 +0800 Message-Id: <1590575610-4546-1-git-send-email-yanghui.def@gmail.com> X-Mailer: git-send-email 2.7.4 X-Rspamd-Queue-Id: 00A981804E3B5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: From: YangHui if pte_alloc_one fail alloc a page, do_fault_around will return 0. and in do_read_fault()->__do_fault(), it also pte_alloc_one a page. if pte_alloc_one failed to alloc a page,it will return VM_FAULT_OOM. To reduce code complexity,if alloc failed we return VM_FAULT_OOM. Signed-off-by: YangHui --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index f703fe8..b104879 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3800,7 +3800,7 @@ static vm_fault_t do_fault_around(struct vm_fault *vmf) if (pmd_none(*vmf->pmd)) { vmf->prealloc_pte = pte_alloc_one(vmf->vma->vm_mm); if (!vmf->prealloc_pte) - goto out; + return VM_FAULT_OOM; smp_wmb(); /* See comment in __pte_alloc() */ }