From patchwork Thu Dec 12 15:21:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11288559 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 828FA138D for ; Thu, 12 Dec 2019 15:21:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 46036206A5 for ; Thu, 12 Dec 2019 15:21:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bnD6q9cV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46036206A5 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 6A0008E0005; Thu, 12 Dec 2019 10:21:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 64FDE8E0001; Thu, 12 Dec 2019 10:21:46 -0500 (EST) 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 565F08E0005; Thu, 12 Dec 2019 10:21:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0124.hostedemail.com [216.40.44.124]) by kanga.kvack.org (Postfix) with ESMTP id 4077D8E0001 for ; Thu, 12 Dec 2019 10:21:46 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id E9934181AEF0B for ; Thu, 12 Dec 2019 15:21:45 +0000 (UTC) X-FDA: 76256854170.24.dress56_f58c50e9895b X-Spam-Summary: 2,0,0,9ba4d00655df6e00,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::jack@suse.cz,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3874:4321:5007:6119:6261:6653:7514:7875:7903:8660:8957:9413:10004:11026:11473:11658:11914:12043:12114:12296:12297:12438:12517:12519:12555:12895:13069:13148:13161:13229:13230:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21627:21666:30003:30054:30070:30079:30090,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.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:27,LUA_SUMMARY:none X-HE-Tag: dress56_f58c50e9895b X-Filterd-Recvd-Size: 3948 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Dec 2019 15:21:45 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id r11so1146531pjp.12 for ; Thu, 12 Dec 2019 07:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Js17Wa4/edDnXUkZVAsMeS/IoMCk6i0mHI/+LgpgWeM=; b=bnD6q9cVrp5lMMASZZ+vM9YUeyvLN3FsyMKyndQ04uflY5IY0Ph4lBOIQUQH8FkyAN avV4kDaX5RbJx13eb05Hw/2LScK5dbm3CFY054LtiVavwHtKWsgniHf9u04FUmmzbldt kD6oEs4fM3jqYfQD0tIusGN3O9aJyVyFfiEHt5sLF7YQrfM+GfVJpjaAwVc44yPzDV8O zbKn0JtJbzwpGDqZnAPg4YpEfCR4Ke/kPS0v0bNeVH2cq7tHbN75gYZM5OCxAphWC7VX ye/4jGazGSdoc9vlcKDH6rUwebDqLHckuTHQbwWzyCEgUlNSQ52NCuqvo4C9kpQv4Rc6 44vg== 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=Js17Wa4/edDnXUkZVAsMeS/IoMCk6i0mHI/+LgpgWeM=; b=SI60CZHwf6LTtKkb1s6HWWmGNsDT4loKFsiURk20niMnfYSieTpAfqNbxiBztNBh7V 9yUSRPzSqa32WnufOT/ahrXfL+CEE/vde5mOdwju0I97Qsmd9I0MEPCHPVux1YD6gvGB 6fineR0HgFowkP+mebMkMxeDALNYf5GLonwpwIV6BhDj1Z+fa7Wc0qv28MOQ0hyHGUME t4EgA/AQlSsHFrQGcnR9VP+BS7AVAIWHYFI2GzJahwaaIFeDlVxeu6td6J1VxPnvc2pS h4SD+9rvYWIKEf1xPkOyZ48vE/ffye9BWKfv3MO1aCsXIEmaA72lVopPNQypfjsTKLuT P2og== X-Gm-Message-State: APjAAAVumH64oOQ/yWp2DusEU08tgZO07P03Xeukg7eMPF0kGxdTGh4s hMgJvluQCTe+o7kj/9zs+k6pMqAN X-Google-Smtp-Source: APXvYqx3xzOlhpRtY2XswcTrnyiYF4CoFVGbAEny+ywOiIA4ojyNQC4dvt0NcWgp9Z6svQsI1MkWsA== X-Received: by 2002:a17:902:a707:: with SMTP id w7mr10142640plq.242.1576164103915; Thu, 12 Dec 2019 07:21:43 -0800 (PST) Received: from binjiang-hz-dhcp091254.china.nsn-net.net ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id h7sm8333016pfq.36.2019.12.12.07.21.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Dec 2019 07:21:43 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: Jan Kara Subject: [PATCH] mm/memory.c: avoid repeated set_page_dirty in fault_dirty_shared_page Date: Thu, 12 Dec 2019 23:21:18 +0800 Message-Id: <1576164078-28402-1-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: When vm_ops->page_mkwrite is defined, and called from wp_page_shared and do_shared_fault, the set_page_dirty must already called by page_mkwrite. Then in fault_dirty_shared_page, avoid this repeated call. Signed-off-by: Li Xinhai Cc: Jan Kara --- mm/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 606da18..34a83d7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2300,10 +2300,11 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; struct address_space *mapping; struct page *page = vmf->page; - bool dirtied; + bool dirtied = false; bool page_mkwrite = vma->vm_ops && vma->vm_ops->page_mkwrite; - dirtied = set_page_dirty(page); + if(!page_mkwrite) + dirtied = set_page_dirty(page); VM_BUG_ON_PAGE(PageAnon(page), page); /* * Take a local copy of the address_space - page.mapping may be zeroed @@ -3645,7 +3646,7 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) * Check if the backing address space wants to know that the page is * about to become writable */ - if (vma->vm_ops->page_mkwrite) { + if (vma->vm_ops && vma->vm_ops->page_mkwrite) { unlock_page(vmf->page); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp ||