From patchwork Fri Jan 31 06:11:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 232296 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no 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 67EADC33CB2 for ; Fri, 31 Jan 2020 06:11:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35C1C214D8 for ; Fri, 31 Jan 2020 06:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451063; bh=gZnMHpmgJdAp9IfWwMGqKfeNJeEIeoMs4HZnqRiR7sQ=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=IjsWHaBDJ6LnevzH+Xk5pXEbZLwigluZ3SS8dh2cdNrWvhlE0SLDsXXRpj0N4bfHL Zd1uDuJyjUHbki4UUXkLIhWWWFlGp7cWeUFvCApxyY10iI9AIaMIOfmkPJfExBJM0l VAHgNtgXKAjflLKnGUxqVfakMds4calxe4WB/GO4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726023AbgAaGLC (ORCPT ); Fri, 31 Jan 2020 01:11:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:57766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbgAaGLC (ORCPT ); Fri, 31 Jan 2020 01:11:02 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A863420663; Fri, 31 Jan 2020 06:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451062; bh=gZnMHpmgJdAp9IfWwMGqKfeNJeEIeoMs4HZnqRiR7sQ=; h=Date:From:To:Subject:In-Reply-To:From; b=t303P3GfkSCMcKA/Ebj+2O/N9FrED5ilnVBRAFC0BzBrvO0kuILkj+bfKwfYdS9DB +Ga1cvwE8YqPYiKD/Q5+rnyvghZmG863Hoo+t9IfQxbBwbmgEojuMLQZXzQXajq/aZ 9Q1YbWvVyBqnHfEk40MNdqTsO40hAsQzGwXpf+gg= Date: Thu, 30 Jan 2020 22:11:01 -0800 From: Andrew Morton To: akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, linux-mm@kvack.org, linux@rasmusvillemoes.dk, linux@roeck-us.net, mm-commits@vger.kernel.org, stable@vger.kernel.org, torvalds@linux-foundation.org, yury.norov@gmail.com Subject: [patch 001/118] lib/test_bitmap: correct test data offsets for 32-bit Message-ID: <20200131061101.ZKr-lpeii%akpm@linux-foundation.org> In-Reply-To: <20200130221021.5f0211c56346d5485af07923@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Andy Shevchenko Subject: lib/test_bitmap: correct test data offsets for 32-bit On 32-bit platform the size of long is only 32 bits which makes wrong offset in the array of 64 bit size. Calculate offset based on BITS_PER_LONG. Link: http://lkml.kernel.org/r/20200109103601.45929-1-andriy.shevchenko@linux.intel.com Fixes: 30544ed5de43 ("lib/bitmap: introduce bitmap_replace() helper") Signed-off-by: Andy Shevchenko Reported-by: Guenter Roeck Cc: Rasmus Villemoes Cc: Yury Norov Cc: Signed-off-by: Andrew Morton --- lib/test_bitmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/lib/test_bitmap.c~lib-test_bitmap-correct-test-data-offsets-for-32-bit +++ a/lib/test_bitmap.c @@ -275,22 +275,23 @@ static void __init test_copy(void) static void __init test_replace(void) { unsigned int nbits = 64; + unsigned int nlongs = DIV_ROUND_UP(nbits, BITS_PER_LONG); DECLARE_BITMAP(bmap, 1024); bitmap_zero(bmap, 1024); - bitmap_replace(bmap, &exp2[0], &exp2[1], exp2_to_exp3_mask, nbits); + bitmap_replace(bmap, &exp2[0 * nlongs], &exp2[1 * nlongs], exp2_to_exp3_mask, nbits); expect_eq_bitmap(bmap, exp3_0_1, nbits); bitmap_zero(bmap, 1024); - bitmap_replace(bmap, &exp2[1], &exp2[0], exp2_to_exp3_mask, nbits); + bitmap_replace(bmap, &exp2[1 * nlongs], &exp2[0 * nlongs], exp2_to_exp3_mask, nbits); expect_eq_bitmap(bmap, exp3_1_0, nbits); bitmap_fill(bmap, 1024); - bitmap_replace(bmap, &exp2[0], &exp2[1], exp2_to_exp3_mask, nbits); + bitmap_replace(bmap, &exp2[0 * nlongs], &exp2[1 * nlongs], exp2_to_exp3_mask, nbits); expect_eq_bitmap(bmap, exp3_0_1, nbits); bitmap_fill(bmap, 1024); - bitmap_replace(bmap, &exp2[1], &exp2[0], exp2_to_exp3_mask, nbits); + bitmap_replace(bmap, &exp2[1 * nlongs], &exp2[0 * nlongs], exp2_to_exp3_mask, nbits); expect_eq_bitmap(bmap, exp3_1_0, nbits); } From patchwork Fri Jan 31 06:11:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 232295 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no 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 8FB89C33CB2 for ; Fri, 31 Jan 2020 06:11:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59C5E22522 for ; Fri, 31 Jan 2020 06:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451069; bh=vpsxjURaJ+1tZ+ToK+fDX7WaU2fULE0P/OkFaMA6/Nk=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=OIa9B9SponY6ySP0KZhLI40gy2mkYrTW9ZKhH4Lduh+/e+YGuGGbcL12LWBKS1JF0 mEwI7C5y1dj+388EA4vF3hBzNw0KTELniBCUzodhdDzvn+IcNOipiBJY7ihVgN/u44 /K5ISRdRFS6gy3g7Ercgq6Ps2hOcQrezjkZDdTRw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbgAaGLJ (ORCPT ); Fri, 31 Jan 2020 01:11:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:57924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbgAaGLI (ORCPT ); Fri, 31 Jan 2020 01:11:08 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 098DD21734; Fri, 31 Jan 2020 06:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451068; bh=vpsxjURaJ+1tZ+ToK+fDX7WaU2fULE0P/OkFaMA6/Nk=; h=Date:From:To:Subject:In-Reply-To:From; b=x0XEz+KGL42PVjPAASfmn1uoCzF3aX+X0XwYw4621SX/LqZ/TzjEkNtzAEtgtZ6UR XW7OHC2/Se2VQEr1tsYSAP//p7G6rO0EDLlsjc26aqDNuFFDJeH8XLxphfVR0CG00s bijqsGHZrakyI0fXWqSLjhOU0/y0GOFjHq052gl0= Date: Thu, 30 Jan 2020 22:11:07 -0800 From: Andrew Morton To: aarcange@redhat.com, akpm@linux-foundation.org, dan.carpenter@oracle.com, hughd@google.com, lee.schermerhorn@hp.com, linux-mm@kvack.org, mhocko@kernel.org, mm-commits@vger.kernel.org, stable@vger.kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz Subject: [patch 003/118] mm/mempolicy.c: fix out of bounds write in mpol_parse_str() Message-ID: <20200131061107.US9oQYBpA%akpm@linux-foundation.org> In-Reply-To: <20200130221021.5f0211c56346d5485af07923@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter Subject: mm/mempolicy.c: fix out of bounds write in mpol_parse_str() What we are trying to do is change the '=' character to a NUL terminator and then at the end of the function we restore it back to an '='. The problem is there are two error paths where we jump to the end of the function before we have replaced the '=' with NUL. We end up putting the '=' in the wrong place (possibly one element before the start of the buffer). Link: http://lkml.kernel.org/r/20200115055426.vdjwvry44nfug7yy@kili.mountain Reported-by: syzbot+e64a13c5369a194d67df@syzkaller.appspotmail.com Fixes: 095f1fc4ebf3 ("mempolicy: rework shmem mpol parsing and display") Signed-off-by: Dan Carpenter Acked-by: Vlastimil Babka Dmitry Vyukov Cc: Michal Hocko Cc: Dan Carpenter Cc: Lee Schermerhorn Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Signed-off-by: Andrew Morton --- mm/mempolicy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/mm/mempolicy.c~mm-mempolicyc-fix-out-of-bounds-write-in-mpol_parse_str +++ a/mm/mempolicy.c @@ -2821,6 +2821,9 @@ int mpol_parse_str(char *str, struct mem char *flags = strchr(str, '='); int err = 1, mode; + if (flags) + *flags++ = '\0'; /* terminate mode string */ + if (nodelist) { /* NUL-terminate mode or flags string */ *nodelist++ = '\0'; @@ -2831,9 +2834,6 @@ int mpol_parse_str(char *str, struct mem } else nodes_clear(nodes); - if (flags) - *flags++ = '\0'; /* terminate mode string */ - mode = match_string(policy_modes, MPOL_MAX, str); if (mode < 0) goto out; From patchwork Fri Jan 31 06:11:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 232294 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no 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 7FF18C33CB2 for ; Fri, 31 Jan 2020 06:11:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BD63217BA for ; Fri, 31 Jan 2020 06:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451076; bh=tnCwpTxo0/s1oqDt3RmMx1eueJ8xh0f88jHvOyCbfJk=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=H3kAUcYdEFGbTMt+akghVGwLpI9ksIR2Z/BTuK7g2Ops9k1nyAFOpAk81/N8zAJh7 SXGCG+krqhhJM7L+TNlSzQry8wVGGzFQqCfm4lj5U0zVGLzk8rW/A5YPDlNw/IHz2e ZowPxHIxeBpBrbQURDPAldGNO6ke78Jf4p9vfmmc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728085AbgAaGLP (ORCPT ); Fri, 31 Jan 2020 01:11:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:58126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbgAaGLP (ORCPT ); Fri, 31 Jan 2020 01:11:15 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8842D206A2; Fri, 31 Jan 2020 06:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451074; bh=tnCwpTxo0/s1oqDt3RmMx1eueJ8xh0f88jHvOyCbfJk=; h=Date:From:To:Subject:In-Reply-To:From; b=sL11XvxfmFCGbvkUTbRfsawZgKRYg7vVp48uS9D4GzSrb+rG8XQeNlmT/QYybtu4/ c4p4Rs7hfSjCZm5Sj1P6ceqRPtc4Z+8VmShb8DT0DhLBWI/9d0AszuosbxvWiYw5DW piyzcvPWXDWrvkZ/7/ypAL//59+KvIEuGuclQOsw= Date: Thu, 30 Jan 2020 22:11:14 -0800 From: Andrew Morton To: akpm@linux-foundation.org, cl@linux.com, jhubbard@nvidia.com, linux-mm@kvack.org, mhocko@kernel.org, mm-commits@vger.kernel.org, richardw.yang@linux.intel.com, stable@vger.kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz, yang.shi@linux.alibaba.com Subject: [patch 005/118] mm/migrate.c: also overwrite error when it is bigger than zero Message-ID: <20200131061114.osgPV4cwc%akpm@linux-foundation.org> In-Reply-To: <20200130221021.5f0211c56346d5485af07923@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wei Yang Subject: mm/migrate.c: also overwrite error when it is bigger than zero If we get here after successfully adding page to list, err would be 1 to indicate the page is queued in the list. Current code has two problems: * on success, 0 is not returned * on error, if add_page_for_migratioin() return 1, and the following err1 from do_move_pages_to_node() is set, the err1 is not returned since err is 1 And these behaviors break the user interface. Link: http://lkml.kernel.org/r/20200119065753.21694-1-richardw.yang@linux.intel.com Fixes: e0153fc2c760 ("mm: move_pages: return valid node id in status if the page is already on the target node"). Signed-off-by: Wei Yang Acked-by: Yang Shi Cc: John Hubbard Cc: Vlastimil Babka Cc: Christoph Lameter Cc: Michal Hocko Cc: Signed-off-by: Andrew Morton --- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/migrate.c~mm-migratec-also-overwrite-error-when-it-is-bigger-than-zero +++ a/mm/migrate.c @@ -1676,7 +1676,7 @@ out_flush: err1 = do_move_pages_to_node(mm, &pagelist, current_node); if (!err1) err1 = store_status(status, start, current_node, i - start); - if (!err) + if (err >= 0) err = err1; out: return err; From patchwork Fri Jan 31 06:11:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 232293 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no 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 3497DC33CB2 for ; Fri, 31 Jan 2020 06:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BBA1214D8 for ; Fri, 31 Jan 2020 06:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451083; bh=ejarE+y0OViZxzeFVS7W7uaA79PRLRXmuUFtmoZWAMk=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=ZjjC+JKHDAnyr/coo7rpaTmJJJDb9mnOM5D49TPZz5r8TQV1+8FPeTTJUMHo5Spyg RSkhMHyDoFOmRQZVpsltLIGo6F2tprvq7kUuMUqZ7bmClhQWr93Hm+nekAvxWS9IKY 0unN58z9ok5WnFp0pR632cXzq0zk7W5Cy2RrgopY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbgAaGLW (ORCPT ); Fri, 31 Jan 2020 01:11:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:58264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbgAaGLW (ORCPT ); Fri, 31 Jan 2020 01:11:22 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 422A720663; Fri, 31 Jan 2020 06:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451081; bh=ejarE+y0OViZxzeFVS7W7uaA79PRLRXmuUFtmoZWAMk=; h=Date:From:To:Subject:In-Reply-To:From; b=Flmjbxgh8Qk7Wn2TAKUuQzxKveuMiDLsGbZ8Wf1sVgTwotSMCm51HXHlaTPNtzsJ5 JVY3LnZFvzB4ts+WL24ob2FDuB1JkVRPkpdUuGWJEdGZoh+wQyLmgNAi/UCfLNO2OJ shxjBtHc87yLPAfVO1cDCR8PbsfVS85lbiZDPMEI= Date: Thu, 30 Jan 2020 22:11:20 -0800 From: Andrew Morton To: akpm@linux-foundation.org, hannes@cmpxchg.org, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mhocko@suse.com, mm-commits@vger.kernel.org, richardw.yang@linux.intel.com, rientjes@google.com, stable@vger.kernel.org, torvalds@linux-foundation.org, vdavydov.dev@gmail.com, yang.shi@linux.alibaba.com Subject: [patch 007/118] mm: thp: don't need care deferred split queue in memcg charge move path Message-ID: <20200131061120.Dchl2XxfT%akpm@linux-foundation.org> In-Reply-To: <20200130221021.5f0211c56346d5485af07923@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wei Yang Subject: mm: thp: don't need care deferred split queue in memcg charge move path If compound is true, this means it is a PMD mapped THP. Which implies the page is not linked to any defer list. So the first code chunk will not be executed. Also with this reason, it would not be proper to add this page to a defer list. So the second code chunk is not correct. Based on this, we should remove the defer list related code. [yang.shi@linux.alibaba.com: better patch title] Link: http://lkml.kernel.org/r/20200117233836.3434-1-richardw.yang@linux.intel.com Fixes: 87eaceb3faa5 ("mm: thp: make deferred split shrinker memcg aware") Signed-off-by: Wei Yang Suggested-by: Kirill A. Shutemov Acked-by: Yang Shi Cc: David Rientjes Cc: Michal Hocko Cc: Kirill A. Shutemov Cc: Johannes Weiner Cc: Vladimir Davydov Cc: [5.4+] Signed-off-by: Andrew Morton --- mm/memcontrol.c | 18 ------------------ 1 file changed, 18 deletions(-) --- a/mm/memcontrol.c~mm-thp-remove-the-defer-list-related-code-since-this-will-not-happen +++ a/mm/memcontrol.c @@ -5340,14 +5340,6 @@ static int mem_cgroup_move_account(struc __mod_lruvec_state(to_vec, NR_WRITEBACK, nr_pages); } -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (compound && !list_empty(page_deferred_list(page))) { - spin_lock(&from->deferred_split_queue.split_queue_lock); - list_del_init(page_deferred_list(page)); - from->deferred_split_queue.split_queue_len--; - spin_unlock(&from->deferred_split_queue.split_queue_lock); - } -#endif /* * It is safe to change page->mem_cgroup here because the page * is referenced, charged, and isolated - we can't race with @@ -5357,16 +5349,6 @@ static int mem_cgroup_move_account(struc /* caller should have done css_get */ page->mem_cgroup = to; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (compound && list_empty(page_deferred_list(page))) { - spin_lock(&to->deferred_split_queue.split_queue_lock); - list_add_tail(page_deferred_list(page), - &to->deferred_split_queue.split_queue); - to->deferred_split_queue.split_queue_len++; - spin_unlock(&to->deferred_split_queue.split_queue_lock); - } -#endif - spin_unlock_irqrestore(&from->move_lock, flags); ret = 0; From patchwork Fri Jan 31 06:12:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 232292 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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no 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 A1E0DC33CB2 for ; Fri, 31 Jan 2020 06:12:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76F972464B for ; Fri, 31 Jan 2020 06:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451173; bh=WIY7V7L5gqqMK/BeKpCdFsRN/WRQshodkTF3WA6WadE=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=mR3fe5stQM/c5m+huBxP7hgvQJAnTqiiMeH1O1sC+SqrUNrEENIBE2G6l+acE92Pm Kh65scMj3Ip28MW73aCdYI2Ks7qTd1S/RDWzgJlDImThLu6TO/DQNSZok2sVCnqtIc r6KatEtcAugbJOA25MocUreVnelmxZGos5Z8ZovQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726488AbgAaGMx (ORCPT ); Fri, 31 Jan 2020 01:12:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:60258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726399AbgAaGMx (ORCPT ); Fri, 31 Jan 2020 01:12:53 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FD33214D8; Fri, 31 Jan 2020 06:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580451172; bh=WIY7V7L5gqqMK/BeKpCdFsRN/WRQshodkTF3WA6WadE=; h=Date:From:To:Subject:In-Reply-To:From; b=kBMXjjn1Qw56Xoy48uQ+iOMKV0ldHyfHyII0sQcMGKYIKwff+js5kktlN0KpcvTxI OJaQvtZb+QLUT0CzULXq+abghsBD7OR1yc/u4BgmFr/ndDUlshIBp3kp7t8yc5f+Ml TCtq8Js+h8jjBuHKjcwZf+wn5Nyxm9N/Tk8ymMO8= Date: Thu, 30 Jan 2020 22:12:50 -0800 From: Andrew Morton To: akpm@linux-foundation.org, alex.williamson@redhat.com, aneesh.kumar@linux.ibm.com, axboe@kernel.dk, bjorn.topel@intel.com, corbet@lwn.net, dan.j.williams@intel.com, daniel.vetter@ffwll.ch, hch@lst.de, hverkuil-cisco@xs4all.nl, ira.weiny@intel.com, jack@suse.cz, jgg@mellanox.com, jgg@ziepe.ca, jglisse@redhat.com, jhubbard@nvidia.com, kirill@shutemov.name, leonro@mellanox.com, linux-mm@kvack.org, mchehab@kernel.org, mm-commits@vger.kernel.org, rppt@linux.ibm.com, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 033/118] media/v4l2-core: set pages dirty upon releasing DMA buffers Message-ID: <20200131061250.z37jD6vNq%akpm@linux-foundation.org> In-Reply-To: <20200130221021.5f0211c56346d5485af07923@linux-foundation.org> User-Agent: s-nail v14.8.16 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: John Hubbard Subject: media/v4l2-core: set pages dirty upon releasing DMA buffers After DMA is complete, and the device and CPU caches are synchronized, it's still required to mark the CPU pages as dirty, if the data was coming from the device. However, this driver was just issuing a bare put_page() call, without any set_page_dirty*() call. Fix the problem, by calling set_page_dirty_lock() if the CPU pages were potentially receiving data from the device. Link: http://lkml.kernel.org/r/20200107224558.2362728-11-jhubbard@nvidia.com Signed-off-by: John Hubbard Reviewed-by: Christoph Hellwig Acked-by: Hans Verkuil Cc: Mauro Carvalho Chehab Cc: Cc: Alex Williamson Cc: Aneesh Kumar K.V Cc: Björn Töpel Cc: Daniel Vetter Cc: Dan Williams Cc: Ira Weiny Cc: Jan Kara Cc: Jason Gunthorpe Cc: Jason Gunthorpe Cc: Jens Axboe Cc: Jerome Glisse Cc: Jonathan Corbet Cc: Kirill A. Shutemov Cc: Leon Romanovsky Cc: Mike Rapoport Signed-off-by: Andrew Morton --- drivers/media/v4l2-core/videobuf-dma-sg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/media/v4l2-core/videobuf-dma-sg.c~media-v4l2-core-set-pages-dirty-upon-releasing-dma-buffers +++ a/drivers/media/v4l2-core/videobuf-dma-sg.c @@ -349,8 +349,11 @@ int videobuf_dma_free(struct videobuf_dm BUG_ON(dma->sglen); if (dma->pages) { - for (i = 0; i < dma->nr_pages; i++) + for (i = 0; i < dma->nr_pages; i++) { + if (dma->direction == DMA_FROM_DEVICE) + set_page_dirty_lock(dma->pages[i]); put_page(dma->pages[i]); + } kfree(dma->pages); dma->pages = NULL; }