Commit Graph

8941 Commits

Author SHA1 Message Date
caelli 5937034c29 Revert "default/config: set CONFIG_TCM_USER2 as module"
This reverts commit 1265b88089.
2022-06-27 21:17:41 +08:00
Menglong Dong 3a4384db67 bpf: fix double free for btf in map_create()
'btf' is freed by btf_put() in map_create() if map_check_btf() fails.
However, it is freed again in free_map, which cause use-after-free
in the later process.

Fix this by remove redundant btf_put().

Fixes: c421e6e7b3 ("copy part code from commid id 85d33df357b634649ddbe0a20fd2d0fc5732c3cb to linux 5.4 to fix sockhash map creation fail problem")

Signed-off-by: Menglong Dong <imagedong@tencent.com>
2021-11-30 10:38:54 +08:00
katrinzhou 1265b88089 default/config: set CONFIG_TCM_USER2 as module 2021-11-02 16:19:31 +08:00
markwhwu 2f5128a765 tcp: export sysctl_tcp_pingpong_thresh
Signed-off-by: Mark Whwu <markwhwu@tencent.com>
2021-11-01 15:13:59 +08:00
caelli b80247552b cgroupfs: support for proc and sys
export files such as cpuinfo, meminfo, stat and so on, which can by used
by containers.

Signed-off-by: caelli <caelli@tencent.com>
Reviewed-by: Peng Hao <flyingpeng@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2021-11-01 15:00:06 +08:00
caelli 5990ae24e7 cgroupfs: quota aware support
add quota aware support when showing container
cpuinfo and stat information.

Signed-off-by: caelli <caelli@tencent.com>
Reviewed-by: Peng Hao <flyingpeng@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2021-11-01 15:00:06 +08:00
caelli 2d555b2cfe cgroupfs: refactor cgroup resource statistics for reuse.
Signed-off-by: caelli <caelli@tencent.com>
Reviewed-by: Peng Hao <flyingpeng@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2021-11-01 15:00:06 +08:00
markwhwu a518984de2 virtio_net: disable cb aggressively
upstream commit:a7766ef18b33674fa164e2e2916cef16d4e17f43

    There are currently two cases where we poll TX vq not in response to a
    callback: start xmit and rx napi.  We currently do this with callbacks
    enabled which can cause extra interrupts from the card.  Used not to be
    a big issue as we run with interrupts disabled but that is no longer the
    case, and in some cases the rate of spurious interrupts is so high
    linux detects this and actually kills the interrupt.

    Fix up by disabling the callbacks before polling the tx vq.

    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-10-29 08:50:28 +00:00
markwhwu eb4eba5e09 virtio_net: move txq wakeups under tx q lock
upstream commit:22bc63c58e876cc359d0b1566dee3db8ecc16722

    We currently check num_free outside tx q lock
    which is unsafe: new packets can arrive meanwhile
    and there won't be space in the queue.
    Thus a spurious queue wakeup causing overhead
    and even packet drops.

    Move the check under the lock to fix that.

    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-10-29 08:50:28 +00:00
markwhwu 6ea1ce5294 virtio_net: move tx vq operation under tx queue lock
upstream commit: 5a2f966d0f3fa0ef6dada7ab9eda74cacee96b8a

    It's unsafe to operate a vq from multiple threads.
    Unfortunately this is exactly what we do when invoking
    clean tx poll from rx napi.
    Same happens with napi-tx even without the
    opportunistic cleaning from the receive interrupt: that races
    with processing the vq in start_xmit.

    As a fix move everything that deals with the vq to under tx lock.

    Fixes: b92f1e6751a6 ("virtio-net: transmit napi")
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-10-29 08:50:28 +00:00
markwhwu efa6c27cf1 virtio_net: Remove BUG() to avoid machine dead
upstream commit:85eb1389458d134bdb75dad502cc026c3753a619

    We should not directly BUG() when there is hdr error, it is
    better to output a print when such error happens. Currently,
    the caller of xmit_skb() already did it.

    Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
2021-10-29 08:50:28 +00:00
markwhwu 109f6104d2 virtio_net: check virtqueue_add_sgs() return value
upstream commit: 222722bc6ebfabf5d54467070f05cf9c0a55ea8c

    As virtqueue_add_sgs() can fail, we should check the return value.

    Addresses-Coverity-ID: 1464439 ("Unchecked return value")
    Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
2021-10-29 08:50:28 +00:00
markwhwu 0ff3e24928 virtio_net: disable napi_tx by default
NAPI-TX causes high hi and si cpu usage and a regression of
18% when perfoming wrk http benchmark.Also,NAPI-TX can be enabled by:
    ifconfig eth0 down
    ethtool -C eth0 tx-frames 1
    ifconfig eth0 up

Signed-off-by: Munger Jiang <mungerjiang@tencent.com>
2021-10-29 08:50:28 +00:00
markwhwu ad9aa4da1e tcp: Change the TCP_PINGPONG_THRESH macro to a variable
The TCP_PINGPONG_THRESH parameter affects nginx performance.
When the default value is set to 1, the requested QPS is 13% higher than when it is set to 3

Use sysctl -w net.core.tcp_pingpong_thresh=%d to change the default value

Signed-off-by: Mark Whwu <markwhwu@tencent.com>
2021-10-29 08:50:28 +00:00
markwhwu 4bba8351f9 mm: enable transparent hugepage by default
Signed-off-by: Mark whwu <markwhwu@tencent.com>
2021-10-29 08:50:28 +00:00
markwhwu 112b81aef0 sched: disable sched_auto_group by default
Autogroup is optimized for desktop interaction and is obviously a negative optimization for UnixBench

Signed-off-by: Mark Whwu <markwhwu@tencent.com>
2021-10-29 08:50:28 +00:00
Bin Lai f91939a5b3 sli/cpu: introduce sli max latency metrics
Sli max latency is lightweight latency monitor metrics, the monitor
tool could get the data with a little overhead. And the accuracy of
the metrics is controlled by the sampling frequency of the monitor
tool. When the performance jitter was occurred in the system, we can
get some help from these lateny metris.

Signed-off-by: Bin Lai <robinlai@tencent.com>
Reviewed-by: benbjiang<benbjiang@tencent.com>
Reviewed-by: Mengmeng Chen <bauerchen@tencent.com>
Reviewed-by: mungerjiang <mungerjiang@tencent.com>
2021-10-29 06:51:52 +00:00
mungerjiang 95a8c85b7f sli/cpu: introduce longsys check
When a process is running in the system space, it cann't be preempted until
it return to userspace, even if the process should be reschedule and other
process was ready to run(because the server system close the kernel preempt
by default). This schedule delay may impact the performance of waiting process,
therefor we introduce the longsys check to collect the schedule delay information
of process. The longsys indication could help us spot the possible performance
jitter in the system.

Signed-off-by: Munger jiang <mungerjiang@tencent.com>
Signed-off-by: Bin Lai <robinlai@tencent.com>
Reviewed-by: benbjiang<benbjiang@tencent.com>
Reviewed-by: Bauerchen <bauerchen@tencent.com>
2021-10-29 06:51:52 +00:00
mungerjiang a76d37e2f4 sli: enable sli in cgroup v1
Signed-off-by: Munger jiang <mungerjiang@tencent.com>
Reviewed-by: Bauerchen <bauerchen@tencent.com>
2021-10-29 06:51:52 +00:00
mungerjiang 674dd9febe sli: fix sli_memlat_stat_start bug
Fix the issue that sli_no_enabled is true in sli_memlat_stat_start,
but sli_no_enabled is false in sli_memlat_stat_end,if *start* is
not zero,sli_memlat_stat_end would get a bad stat.

Signed-off-by: Munger jiang <mungerjiang@tencent.com>
2021-10-29 06:51:52 +00:00
mungerjiang 3585e8f134 sli/cpu: Add sched latency account
Signed-off-by: Munger jiang <mungerjiang@tencent.com>
2021-10-29 06:51:52 +00:00
mungerjiang e8c34acd40 sli/memory: Add memory latency account
Signed-off-by: Munger jiang <mungerjiang@tencent.com>
2021-10-29 06:51:52 +00:00
Bin Lai b879b1b64b sli: Introduce memory and sched latency stat infrastructure
Signed-off-by: Munger jiang <mungerjiang@tencent.com>
2021-10-29 06:51:52 +00:00
Bauerchen c44986b358 tqos/cpu: load.r/load.d support cgroup V2
Signed-off-by: Bauerchen <bauerchen@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2021-10-29 06:51:52 +00:00
Bauerchen 8003819c11 tqos/cpu: add cgroup load.r/load.d statistic
Now cgroup loadavg calcuted according processes in R state and D state,
sometimes we need more specific information, so just calcuting loadavg
separately.

Line2 is load.r and line3 is load.d. When most process
do IO operation and we may get the output like this:

[root@VM-130-27-centos test]# cat cpuset.loadavg
20.03 9.85 3.88 1/339 3852
6.56 3.96 1.62
13.46 5.89 2.27

Signed-off-by: Bauerchen <bauerchen@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2021-10-29 06:51:52 +00:00
Bauerchen c07a089a0f tqos/mbuf: export mbuf interface to cpuacct subsys
In cgroup V1, mbuf only exist in cpuacct subsys, so we may need a help
function to store buffer just according process task_struct.

Signed-off-by: Bauerchen <bauerchen@tencent.com>
Reviewed-by: mungerjiang<mungerjiang@tencent.com>
Reviewed-by: benbjiang<benbjiang@tencent.com>
2021-10-29 06:51:52 +00:00
Bauerchen f813e65898 tqos/mbuf: alloc mbuf slot for cpuacct in cgroup V1
Mbuf support cgroup V1, to compatible with cgroup V2, we only export it
to cpuacct subsys.

Signed-off-by: Bauerchen <bauerchen@tencent.com>
Reviewed-by: mungerjiang<mungerjiang@tencent.com>
Reviewed-by: benbjiang<benbjiang@tencent.com>
2021-10-29 06:51:52 +00:00
Bauerchen 7795ccbf82 tqos/mbuf: write a help function to get cgroup struct from task_struct.
In order to support cgroup V1 with mbuf and sli, we need a special
cgroup structure, cpuacct subsys cgroup is nice.

We only prepare mbuf and sli for cpuacct cgroup in V1. so first find cpuacct
cgroup and if return NULl or root, just find df1_cgrp.

Signed-off-by: Bauerchen <bauerchen@tencent.com>
Reviewed-by: mungerjiang<mungerjiang@tencent.com>
Reviewed-by: mungerjiang<mungerjiang@tencent.com>
2021-10-29 06:51:52 +00:00
Bauerchen 7600f2ca44 tqos/rqm: Tencent Quality Monitor Buffer
Providing back up buffer for Quality Monitor, can be used to catch key
context when abnormal jitters occur. And application can also use it
to detect system env exception.

Signed-off-by: Bauerchen <bauerchen@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
2021-10-29 06:51:52 +00:00
Hongbo Li 589e8a96bc getsockopt: add SO_MARK2 to get the MARK of flow
add SO_MARK2 to get the MARK of flow
backport from tkernel2:
commit c6f2e27f7ad0b97ae0c162f70b6e0375f2270f27

Signed-off-by: Hongbo Li <herberthbli@tencent.com>
Signed-off-by: brookxu <brookxu@tencent.com>
2021-10-29 06:51:37 +00:00
Peng Hao 3df720cae4 mm/lru: revise the comments of lru_lock
Use this new function to replace repeated same code, no func change.

When testing for relock we can avoid the need for RCU locking if we simply
compare the page pgdat and memcg pointers versus those that the lruvec is
holding. By doing this we can avoid the extra pointer walks and accesses of
the memory cgroup.

In addition we can avoid the checks entirely if lruvec is currently NULL.

Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao 1b7478d8d0 mm/lru: replace pgdat lru_lock with lruvec lock
This patch moves per node lru_lock into lruvec, thus bring a lru_lock for
each of memcg per node. So on a large machine, each of memcg don't
have to suffer from per node pgdat->lru_lock competition. They could go
fast with their self lru_lock.

After move memcg charge before lru inserting, page isolation could
serialize page's memcg, then per memcg lruvec lock is stable and could
replace per node lru lock.

In func isolate_migratepages_block, compact_unlock_should_abort and
lock_page_lruvec_irqsave are open coded to work with compact_control.
Also add a debug func in locking which may give some clues if there are
sth out of hands.

Daniel Jordan's testing show 62% improvement on modified readtwice case
on his 2P * 10 core * 2 HT broadwell box.
https://lore.kernel.org/lkml/20200915165807.kpp7uhiw7l3loofu@ca-dmjordan1.us.oracle.com/

On a large machine with memcg enabled but not used, the page's lruvec
seeking pass a few pointers, that may lead to lru_lock holding time
increase and a bit regression.

Hugh Dickins helped on patch polish, thanks!
[flyingpeng: compatibility modification]

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
2021-10-29 06:51:21 +00:00
Peng Hao 821adde85c mm: memcontrol: charge swapin pages on instantiation
Right now, users that are otherwise memory controlled can easily escape
their containment and allocate significant amounts of memory that they're
not being charged for.  That's because swap readahead pages are not being
charged until somebody actually faults them into their page table.  This
can be exploited with MADV_WILLNEED, which triggers arbitrary readahead
allocations without charging the pages.

There are additional problems with the delayed charging of swap pages:

1. To implement refault/workingset detection for anonymous pages, we
   need to have a target LRU available at swapin time, but the LRU is not
   determinable until the page has been charged.

2. To implement per-cgroup LRU locking, we need page->mem_cgroup to be
   stable when the page is isolated from the LRU; otherwise, the locks
   change under us.  But swapcache gets charged after it's already on the
   LRU, and even if we cannot isolate it ourselves (since charging is not
   exactly optional).

The previous patch ensured we always maintain cgroup ownership records for
swap pages.  This patch moves the swapcache charging point from the fault
handler to swapin time to fix all of the above problems.

v2: simplify swapin error checking (Joonsoo)

[hughd@google.com: fix livelock in __read_swap_cache_async()]
[flyingpeng: port New API]
  Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2005212246080.8458@eggly.anvils
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
2021-10-29 06:51:21 +00:00
Peng Hao 4e9dc3310b mm/swap.c: serialize memcg changes in pagevec_lru_move_fn
Hugh Dickins' found a memcg change bug on original version:
If we want to change the pgdat->lru_lock to memcg's lruvec lock, we have
to serialize mem_cgroup_move_account during pagevec_lru_move_fn. The
possible bad scenario would like:

	cpu 0					cpu 1
lruvec = mem_cgroup_page_lruvec()
					if (!isolate_lru_page())
						mem_cgroup_move_account

spin_lock_irqsave(&lruvec->lru_lock <== wrong lock.

So we need TestClearPageLRU to block isolate_lru_page(), that serializes
the memcg change. and then removing the PageLRU check in move_fn callee
as the consequence.

__pagevec_lru_add_fn() is different from the others, because the pages
it deals with are, by definition, not yet on the lru.  TestClearPageLRU
is not needed and would not work, so __pagevec_lru_add() goes its own
way.

Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao f784a238c7 mm/compaction: do page isolation first in compaction
Currently, compaction would get the lru_lock and then do page isolation
 which works fine with pgdat->lru_lock, since any page isoltion would
 compete for the lru_lock. If we want to change to memcg lru_lock, we
 have to isolate the page before getting lru_lock, thus isoltion would
 block page's memcg change which relay on page isoltion too. Then we
 could safely use per memcg lru_lock later.

 The new page isolation use previous introduced TestClearPageLRU() +
 pgdat lru locking which will be changed to memcg lru lock later.

 Hugh Dickins <hughd@google.com> fixed following bugs in this patch's
 early version:

 Fix lots of crashes under compaction load: isolate_migratepages_block()
 must clean up appropriately when rejecting a page, setting PageLRU again
 if it had been cleared; and a put_page() after get_page_unless_zero()
 cannot safely be done while holding locked_lruvec - it may turn out to
 be the final put_page(), which will take an lruvec lock when PageLRU.
 And move __isolate_lru_page_prepare back after get_page_unless_zero to
 make trylock_page() safe:
 trylock_page() is not safe to use at this time: its setting PG_locked
 can race with the page being freed or allocated ("Bad page"), and can
 also erase flags being set by one of those "sole owners" of a freshly
 allocated page who use non-atomic __SetPageFlag().

Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao 4702fd8039 mm/lru: introduce TestClearPageLRU
Currently lru_lock still guards both lru list and page's lru bit, that's
ok. but if we want to use specific lruvec lock on the page, we need to
pin down the page's lruvec/memcg during locking. Just taking lruvec
lock first may be undermined by the page's memcg charge/migration. To
fix this problem, we could clear the lru bit out of locking and use
it as pin down action to block the page isolation in memcg changing.

So now a standard steps of page isolation is following:
	1, get_page(); 	       #pin the page avoid to be free
	2, TestClearPageLRU(); #block other isolation like memcg change
	3, spin_lock on lru_lock; #serialize lru list access
	4, delete page from lru list;
The step 2 could be optimzed/replaced in scenarios which page is
unlikely be accessed or be moved between memcgs.

This patch start with the first part: TestClearPageLRU, which combines
PageLRU check and ClearPageLRU into a macro func TestClearPageLRU. This
function will be used as page isolation precondition to prevent other
isolations some where else. Then there are may !PageLRU page on lru
list, need to remove BUG() checking accordingly.

There 2 rules for lru bit now:
1, the lru bit still indicate if a page on lru list, just in some
   temporary moment(isolating), the page may have no lru bit when
   it's on lru list.  but the page still must be on lru list when the
   lru bit set.
2, have to remove lru bit before delete it from lru list.

As Andrew Morton mentioned this change would dirty cacheline for page
isn't on LRU. But the lost would be acceptable in Rong Chen
<rong.a.chen@intel.com> report:
https://lore.kernel.org/lkml/20200304090301.GB5972@shao2-debian/

[flyingpeng: compatibility code porting]
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
2021-10-29 06:51:21 +00:00
Peng Hao f646d14e7d mm/mlock: remove __munlock_isolate_lru_page
The func only has one caller, remove it to clean up code and simplify
code.

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao fe81043c65 mm/mlock: remove lru_lock on TestClearPageMlocked
In the func munlock_vma_page, comments mentained lru_lock needed for
serialization with split_huge_pages. But the page must be PageLocked
as well as pages in split_huge_page series funcs. Thus the PageLocked
is enough to serialize both funcs.

Further more, Hugh Dickins pointed: before splitting in
split_huge_page_to_list, the page was unmap_page() to remove pmd/ptes
which protect the page from munlock. Thus, no needs to guard
__split_huge_page_tail for mlock clean, just keep the lru_lock there for
isolation purpose.

LKP found a preempt issue on __mod_zone_page_state which need change
to mod_zone_page_state. Thanks!

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao b80a4794f6 mm/vmscan: remove lruvec reget in move_pages_to_lru
A isolated page shouldn't be recharged by memcg since the memcg
migration isn't possible at the time.
So remove unnecessary regetting.

Thanks to Alexander Duyck for pointing this out.

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao fb8db998fd mm/swap.c: fold vm event PGROTATED into pagevec_move_tail_fn
Fold the PGROTATED event collection into pagevec_move_tail_fn call back
func like other funcs does in pagevec_lru_move_fn. Thus we could save
func call pagevec_move_tail().
Now all usage of pagevec_lru_move_fn are same and no needs of its 3rd
parameter.

It's just simply the calling. No functional change.

[lkp@intel.com: found a build issue in the original patch, thanks]
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao a50cb5b4fd mm/memcg: add debug checking in lock_page_memcg
Add a debug checking in lock_page_memcg, then we could get alarm
if anything wrong here.

Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao b85b3df216 mm: page_idle_get_page() does not need lru_lock
It is necessary for page_idle_get_page() to recheck PageLRU() after
get_page_unless_zero(), but holding lru_lock around that serves no
useful purpose, and adds to lru_lock contention: delete it.

See https://lore.kernel.org/lkml/20150504031722.GA2768@blaptop for the
discussion that led to lru_lock there; but __page_set_anon_rmap() now
uses WRITE_ONCE(), and I see no other risk in page_idle_clear_pte_refs()
using rmap_walk() (beyond the risk of racing PageAnon->PageKsm, mostly
but not entirely prevented by page_count() check in ksm.c's
write_protect_page(): that risk being shared with page_referenced() and
not helped by lru_lock).

Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao 03c89871c4 mm/vmscan: remove unnecessary lruvec adding
We don't have to add a freeable page into lru and then remove from it.
  This change saves a couple of actions and makes the moving more clear.

  The SetPageLRU needs to be kept before put_page_testzero for list
  integrity, otherwise:

  #0 move_pages_to_lru             #1 release_pages
  if !put_page_testzero
                                    if (put_page_testzero())
                                       !PageLRU //skip lru_lock
     SetPageLRU()
     list_add(&page->lru,)
                                       list_add(&page->lru,)

[akpm@linux-foundation.org: coding style fixes]
[flyingpeng@tencent.com: use old macro & strip workingset related]
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
2021-10-29 06:51:21 +00:00
Peng Hao df9cd25041 mm/thp: narrow lru locking
lru_lock and page cache xa_lock have no obvious reason to be taken
one way round or the other: until now, lru_lock has been taken before
page cache xa_lock, when splitting a THP; but nothing else takes them
together.  Reverse that ordering: let's narrow the lru locking - but
leave local_irq_disable to block interrupts throughout, like before.

Hugh Dickins point: split_huge_page_to_list() was already silly, to be
using the _irqsave variant: it's just been taking sleeping locks, so
would already be broken if entered with interrupts enabled.  So we
can save passing flags argument down to __split_huge_page().

Why change the lock ordering here? That was hard to decide. One reason:
when this series reaches per-memcg lru locking, it relies on the THP's
memcg to be stable when taking the lru_lock: that is now done after the
THP's refcount has been frozen, which ensures page memcg cannot change.

Another reason: previously, lock_page_memcg()'s move_lock was presumed
to nest inside lru_lock; but now lru_lock must nest inside (page cache
lock inside) move_lock, so it becomes possible to use lock_page_memcg()
to stabilize page memcg before taking its lru_lock.  That is not the
mechanism used in this series, but it is an option we want to keep open.

[Hugh Dickins: rewrite commit log]
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao 3a1dbe1b82 mm/thp: Simplify lru_add_page_tail()
Simplify lru_add_page_tail(), there are actually only two cases possible:
split_huge_page_to_list(), with list supplied and head isolated from lru
by its caller; or split_huge_page(), with NULL list and head on lru -
because when head is racily isolated from lru, the isolator's reference
will stop the split from getting any further than its page_ref_freeze().

So decide between the two cases by "list", but add VM_WARN_ON()s to
verify that they match our lru expectations.

[Hugh Dickins: rewrite commit log]
[flyingpeng: compatibility code modification]
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
2021-10-29 06:51:21 +00:00
Peng Hao 7f63114b93 mm/memcg: bail early from swap accounting if memcg disabled
If we disabled memcg by cgroup_disable=memory, page->memcg will be NULL
and so the charge is skipped and that will trigger a warning like below.
Let's return from the funcs earlier.

 anon flags:0x5005b48008000d(locked|uptodate|dirty|swapbacked)
 raw: 005005b48008000d dead000000000100 dead000000000122 ffff8897c7c76ad1
 raw: 0000000000000022 0000000000000000 0000000200000000 0000000000000000
 page dumped because: VM_WARN_ON_ONCE_PAGE(!memcg)
...
 RIP: 0010:vprintk_emit+0x1f7/0x260
 Code: 00 84 d2 74 72 0f b6 15 27 58 64 01 48 c7 c0 00 d4 72 82 84 d2 74 09 f3 90 0f b6 10 84 d2 75 f7 e8 de 0d 00 00 4c 89 e7 57 9d <0f> 1f 44 00 00 e9 62 ff ff ff 80 3d 88 c9 3a 01 00 0f 85 54 fe ff
 RSP: 0018:ffffc9000faab358 EFLAGS: 00000202
 RAX: ffffffff8272d400 RBX: 000000000000005e RCX: ffff88afd80d0040
 RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000202
 RBP: ffffc9000faab3a8 R08: ffffffff8272d440 R09: 0000000000022480
 R10: 00120c77be68bfac R11: 0000000000cd7568 R12: 0000000000000202
 R13: 0057ffffc0080005 R14: ffffffff820a0130 R15: ffffc9000faab3e8
 ? vprintk_emit+0x140/0x260
 vprintk_default+0x1a/0x20
 vprintk_func+0x4f/0xc4
 ? vprintk_func+0x4f/0xc4
 printk+0x53/0x6a
 ? xas_load+0xc/0x80
 __dump_page.cold.6+0xff/0x4ee
 ? xas_init_marks+0x23/0x50
 ? xas_store+0x30/0x40
 ? free_swap_slot+0x43/0xd0
 ? put_swap_page+0x119/0x320
 ? update_load_avg+0x82/0x580
 dump_page+0x9/0xb
 mem_cgroup_try_charge_swap+0x16e/0x1d0
 get_swap_page+0x130/0x210
 add_to_swap+0x41/0xc0
 shrink_page_list+0x99e/0xdf0
 shrink_inactive_list+0x199/0x360
 shrink_lruvec+0x40d/0x650
 ? _cond_resched+0x14/0x30
 ? _cond_resched+0x14/0x30
 shrink_node+0x226/0x6e0
 do_try_to_free_pages+0xd0/0x400
 try_to_free_pages+0xef/0x130
 __alloc_pages_slowpath.constprop.127+0x38d/0xbd0
 ? ___slab_alloc+0x31d/0x6f0
 __alloc_pages_nodemask+0x27f/0x2c0
 alloc_pages_vma+0x75/0x220
 shmem_alloc_page+0x46/0x90
 ? release_pages+0x1ae/0x410
 shmem_alloc_and_acct_page+0x77/0x1c0
 shmem_getpage_gfp+0x162/0x910
 shmem_fault+0x74/0x210
 ? filemap_map_pages+0x29c/0x410
 __do_fault+0x37/0x190
 handle_mm_fault+0x120a/0x1770
 exc_page_fault+0x251/0x450
 ? asm_exc_page_fault+0x8/0x30
 asm_exc_page_fault+0x1e/0x30

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Peng Hao b18f5a48c9 Add VM_WARN_ON_ONCE_PAGE() macro.
Since readahead page is charged on memcg too, in theory we don't have to
check this exception now. Before safely remove them all, add a warning
for the unexpected !memcg.

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
2021-10-29 06:51:21 +00:00
Fuhai Wang 6a0f0233f8 irqchip: phytium2500: fixed interrupts are concentrated in one cpu 2021-10-19 08:40:52 +00:00
Fuhai Wang cdbc9c0b3f arm/config: set CONFIG_SCSI_MPT3SAS as module
Signed-off-by: Fuhai Wang <fuhaiwang@tencent.com>
2021-10-19 07:18:46 +00:00
Peng Hao e1c207b3e7 fuse: add a dev ioctl for recovery
For a simple read-only file system, as long as the connection
 is not broken, the recovery of the user-mode read-only file
 system process can be realized by putting the request of the
 processing list back into the pending list.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
2021-10-13 04:21:54 +00:00