1. 06 3月, 2023 20 次提交
  2. 15 11月, 2022 4 次提交
    • G
      sharepool: fix sp_alloc_populate no fallocate bug · 60a48ea1
      Guo Mengqi 提交于
      ascend inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I612UG
      CVE: NA
      
      --------------------------------
      
      do_mm_populate() will try allocate physical pages from the start of
      required range [start, end), and return error on the first allocation
      failure without releasing the pages allocated before.
      That means we must release the shared-file range after calling
      do_mm_populate().
      
      Remove need_fallocate, and always call sp_fallocate() on the error path
      of sp_alloc_mmap_populate().
      Signed-off-by: NGuo Mengqi <guomengqi3@huawei.com>
      60a48ea1
    • X
      mm/sharepool: Fix add group failed with errno 28 · 7086bdba
      Xu Qiang 提交于
      ascend inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I612UG
      CVE: NA
      
      --------------------------------
      
      We increase task->mm->mm_users by one when we add the task to a
      sharepool group. Correspondingly we should drop the mm_users count when
      the task exits. Currently we hijack the mmput function and make it
      return early and decrease mm->mm_users by one (just as mmput would do)
      if it is not called from a task's exiting process, or we decrease
      mm->mm_users by the group number the task was added to. This has two
      problems:
      1. It makes mmput and sp_group_exit hard to understand.
      2. The process of judging if the task (also its mm) is exiting and
         decrease its mm_users count is not atomic. We use this condition:
           mm->mm_users == master->count + MM_WOULD_FREE(1)
         If someone else change the mm->mm_users during those two steps, the
         mm->mm_users would be wrong and mm_struct cannot be released anymore.
      
      Suppose the following process:
      
              proc1                                        proc2
      
      1)      mmput
                |
                V
      2)  enter sp_group_exit and
          'mm->mm_users == master->count + 1' is true
      3)        |                                         mmget
                V
      4)  decrease mm->mm_users by master->count
                |
                V
      5)  enter __mmput and release mm_struct
          if mm->mm_users == 1
      6)                                                  mmput
      
      The statistical structure who has the same id of the task would get leaked
      together with mm_struct, so the next time we try to create the statistical
      structure of the same id, we get a failure.
      
      We fix this by moving sp_group_exit to do_exit() actually where the task is
      exiting. We don't need to judge if the task is exiting when someone
      calling mmput so there is no chance to change mm_users wrongly.
      Signed-off-by: NXu Qiang <xuqiang36@huawei.com>
      Signed-off-by: NWang Wensheng <wangwensheng4@huawei.com>
      7086bdba
    • Z
      mm: sharepool: Fix static check warning · fab907d0
      Zhang Zekun 提交于
      ascend inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I612UG
      CVE: NA
      
      --------------------------------
      
      Fix the following static check warning.
      Use parentheses to specify the sequence of expressions, instead of using
      the default priority.Should use parenthesis while use bitwise operator.
      
      Fix this by add bracket in the expression.
      Signed-off-by: NZhang Zekun <zhangzekun11@huawei.com>
      fab907d0
    • Z
      mm/sharepool: Use "tgid" instead of "pid" to find a task · 32c81f1b
      Zhang Zekun 提交于
      ascend inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I612UG
      CVE: NA
      
      --------------------------------
      
      To support container scenario, use tgid instead of pid to find a
      specific task. In normal cases, "tgid" represent a process in init_pid_ns,
      this patch should not introduce problems to existing code.
      
      Rename the input parameter "int pid" to "int tgid" in following
      exported interfaces:
      1.mg_sp_group_id_by_pid()
      2.mg_sp_group_add_task()
      3.mg_sp_group_del_task()
      4.mg_sp_make_share_k2u()
      5.mg_sp_make_share_u2k()
      6.mg_sp_config_dvpp_range()
      
      Besides, rename these static function together:
      1.__sp_find_spg_locked()
      2.__sp_find_spg()
      
      The following function use "current->pid" to find spg, change
      "current->pid" to "current->tgid".
      1.find_or_alloc_sp_group()
      2.sp_alloc_prepare()
      3.mg_sp_make_share_k2u()
      Signed-off-by: NZhang Zekun <zhangzekun11@huawei.com>
      32c81f1b
  3. 09 11月, 2022 16 次提交