LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: Wang Long <wanglong19@meituan.com> To: tj@kernel.org, hannes@cmpxchg.org Cc: gthelen@google.com, npiggin@suse.de, akpm@osdl.org, linux-kernel@vger.kernel.org, wanglong19@meituan.com Subject: [RFC] Is it correctly that the usage for spin_{lock|unlock}_irq in clear_page_dirty_for_io Date: Mon, 2 Apr 2018 19:50:50 +0800 [thread overview] Message-ID: <d5f73e91-6fd5-12ab-d005-93a72e146464@meituan.com> (raw) In-Reply-To: <157ed606-4a61-508b-d26a-2f5d638f39bb@meituan.com> Hi, Johannes Weiner and Tejun Heo I use linux-4.4.y to test the new cgroup controller io and the current stable kernel linux-4.4.y has the follow logic int clear_page_dirty_for_io(struct page *page){ ... ... memcg = mem_cgroup_begin_page_stat(page); ----------(a) wb = unlocked_inode_to_wb_begin(inode, &locked); ---------(b) if (TestClearPageDirty(page)) { mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY); dec_zone_page_state(page, NR_FILE_DIRTY); dec_wb_stat(wb, WB_RECLAIMABLE); ret =1; } unlocked_inode_to_wb_end(inode, locked); -----------(c) mem_cgroup_end_page_stat(memcg); -------------(d) return ret; ... ... } when memcg is moving, and I_WB_SWITCH flags for inode is set. the logic is the following: spin_lock_irqsave(&memcg->move_lock, flags); -------------(a) spin_lock_irq(&inode->i_mapping->tree_lock); ------------(b) spin_unlock_irq(&inode->i_mapping->tree_lock); -----------(c) spin_unlock_irqrestore(&memcg->move_lock, flags); -----------(d) after (c) , the local irq is enabled. I think it is not correct. We get a deadlock backtrace after (c), the cpu get an softirq and in the irq it also call mem_cgroup_begin_page_stat to lock the same memcg->move_lock. Since the conditions are too harsh, this scenario is difficult to reproduce. But it really exists. So how about change (b) (c) to spin_lock_irqsave/spin_lock_irqrestore? Thanks:-)
next parent reply other threads:[~2018-04-02 11:58 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <157ed606-4a61-508b-d26a-2f5d638f39bb@meituan.com> 2018-04-02 11:50 ` Wang Long [this message] 2018-04-03 12:03 ` [RFC] Is it correctly that the usage for spin_{lock|unlock}_irq in clear_page_dirty_for_io Michal Hocko 2018-04-03 23:12 ` Greg Thelen 2018-04-04 6:31 ` Wang Long 2018-04-06 8:03 ` [PATCH] writeback: safer lock nesting Greg Thelen 2018-04-06 8:07 ` Michal Hocko 2018-04-06 18:49 ` Greg Thelen 2018-04-06 18:55 ` [PATCH v2] " Greg Thelen 2018-04-07 18:56 ` kbuild test robot 2018-04-10 0:59 ` [PATCH v3] " Greg Thelen 2018-04-10 6:33 ` Michal Hocko 2018-04-10 20:48 ` Andrew Morton 2018-04-11 5:50 ` Michal Hocko 2018-04-10 8:14 ` Wang Long 2018-04-11 0:40 ` Greg Thelen 2018-04-10 20:37 ` Andrew Morton 2018-04-11 1:03 ` Greg Thelen 2018-04-11 8:46 ` [PATCH v4] " Greg Thelen 2018-04-10 13:50 ` [PATCH] " Sasha Levin 2018-04-11 2:44 ` Wang Long 2018-04-11 3:13 ` Greg Thelen 2018-04-11 8:45 ` [PATCH for-4.4] " Greg Thelen 2018-04-11 8:50 ` Greg Thelen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=d5f73e91-6fd5-12ab-d005-93a72e146464@meituan.com \ --to=wanglong19@meituan.com \ --cc=akpm@osdl.org \ --cc=gthelen@google.com \ --cc=hannes@cmpxchg.org \ --cc=linux-kernel@vger.kernel.org \ --cc=npiggin@suse.de \ --cc=tj@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).