小编bur*_*ino的帖子

ftrace:通过echo从function_graph更改current_tracer时系统崩溃

我最近一直在玩ftrace来监控我系统的某些行为特征.我一直在处理通过一个小脚本打开/关闭跟踪.运行脚本后,我的系统会崩溃并自行重启.最初,我认为脚本本身可能存在错误,但我已经确定崩溃和重启是由于设置为function_graph echo时某些跟踪器到/ sys/kernel/debug/tracing/current_tracer的结果current_tracer.

也就是说,以下命令序列将产生崩溃/重启:

echo "function_graph" > /sys/kernel/debug/tracing/current_tracer
echo "function" > /sys/kernel/debug/tracing/current_tracer
Run Code Online (Sandbox Code Playgroud)

在上述echo语句导致崩溃后重启,我看到很多输出内容如下:

清除孤儿inode <inode>

我试图通过将current_tracerfunction_graph中的值替换为C程序中的其他内容来重现此问题:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

int openCurrentTracer()
{
        int fd = open("/sys/kernel/debug/tracing/current_tracer", O_WRONLY);
        if(fd < 0)
                exit(1);

        return fd;
}

int writeTracer(int fd, char* tracer)
{
        if(write(fd, tracer, strlen(tracer)) != strlen(tracer)) {
                printf("Failure writing %s\n", tracer);
                return 0;
        }

        return 1;
}

int main(int argc, char* argv[])
{
        int fd = openCurrentTracer(); …
Run Code Online (Sandbox Code Playgroud)

linux shell ftrace echo linux-kernel

28
推荐指数
1
解决办法
1052
查看次数

使用git rebase,有没有办法使用默认命令在git-rebase-todo中重写提交消息?

假设我跑了 git rebase -i HEAD~3

pick 6b24464 foo
pick a681432 Foo
pick 8ccba08 foo foo

# Rebase 960c384..8ccba08 onto 960c384
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the …
Run Code Online (Sandbox Code Playgroud)

git git-rebase

17
推荐指数
3
解决办法
5257
查看次数

将符号从.globl更改为.weak的后果是什么?

在上一个问题上花了一些时间之后,用户向我介绍了有关以下问题的电子邮件主题:

[PATCH] ftrace/x86:修复功能图跟踪器重置路径

在我的系统上,只需启用和禁用功能图跟踪器就可以使内核崩溃.直到现在我还不知道它是如何运作的.

假设ftrace_disable_ftrace_graph_caller()jmp指令在ftrace_graph_calljmp(e9)附近是5个字节,则修改jmp指令 .然而,它是一个短的jmp,只包含2个字节(eb).并且 ftrace_stub()位于ftrace_graph_caller上面这样的修改之下,打破导致内核oops的指令ftrace_stub()与无效的操作码如下所示:

此问题的一个解决方案是以下补丁:

 diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
 index ed48a9f465f8..e13a695c3084 100644
 --- a/arch/x86/kernel/mcount_64.S
 +++ b/arch/x86/kernel/mcount_64.S
 @@ -182,7 +182,8 @@ GLOBAL(ftrace_graph_call)
    jmp ftrace_stub
  #endif

 -GLOBAL(ftrace_stub)
 +/* This is weak to keep gas from relaxing the jumps */
 +WEAK(ftrace_stub)
    retq
  END(ftrace_caller)
Run Code Online (Sandbox Code Playgroud)

通过https://lkml.org/lkml/2016/5/16/493

我不明白的作用是什么替换GLOBAL(ftrace_stub)WEAK(ftrace_stub).补丁中包含的注释和查看GLOBAL()WEAK()都没有帮助我理解为什么这个解决方案有效.

正如标题所暗示的那样,我的问题是: 将符号从.globl更改为.weak的后果什么?我希望的是考虑如何更换一个答案GLOBAL(ftrace_stub)WEAK(ftrace_stub)可以解决引用问题.

c linux x86 assembly linux-kernel

7
推荐指数
1
解决办法
109
查看次数

未找到 ID 为“org.springframework.boot”的插件

我想使用 gradle 5.2 将 spring boot 插件包含到我的项目中。下面是我的 build.gradle 的当前状态,接下来是我尝试做的事情。目前,我正在尝试使用 gradle 5 的BOM 支持,但这不是硬性要求。我只想知道如何解决错误

未找到 ID 为“org.springframework/boot”的插件

更新:更新了下面的结构以更好地代表我的用例。

构建.gradle

apply from: 'boot.gradle'
Run Code Online (Sandbox Code Playgroud)

引导.gradle

repositories {
    mavenCentral()
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

dependencies {
    implementation platform('org.springframework.boot:spring-boot-dependencies:2.0.0.RELEASE')

    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.0.0.RELEASE'
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.0.0.RELEASE'

    implementation group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '2.0.0.RELEASE'
}
Run Code Online (Sandbox Code Playgroud)

要重现我的错误,您只需要在项目中再添加一个文件:

应用程序.java

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    } …
Run Code Online (Sandbox Code Playgroud)

java spring gradle spring-boot

6
推荐指数
2
解决办法
2万
查看次数

如何让 Swagger-UI 使用 YAML/JSON 而不必在我的 REST 控制器上添加注释?

我习惯于在我的 REST 控制器上添加注释以供 Swagger-UI 使用。但是,我更愿意将 Swagger-UI 指向描述我的 REST 控制器的 YAML 文件。我想要做的一个例子如下所示。(Springfox/Swagger2)

演示应用程序.java

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

SwaggerConfig.java

请注意,我试图告诉 Swagger 基于 YAML 文件而不是 REST 控制器构建 Docket。

import com.google.common.base.Predicate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static springfox.documentation.builders.PathSelectors.regex;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2).useDefaultResponseMessages(false)
                .select()
                .paths(paths())
                .build();
    }

    private Predicate<String> paths() {
        return regex("/swagger.yml");
    } …
Run Code Online (Sandbox Code Playgroud)

java yaml swagger swagger-ui springfox

5
推荐指数
1
解决办法
3327
查看次数

在 gitlab ci MR 管道上运行所有作业,即使有些作业没有 merge_request_event 规则,但不要同时运行 MR 和分支管道

如果术语不标准,我将使用以下术语:

  • 分支管道:推送到分支时运行的管道。
  • MR 管道:在合并请求上运行或推送到合并请求分支的管道。

我想编写一个包含两个作业的管道,job_A并且job_B. job_A应该在所有管道上运行。 job_B应该只在合并请求管道上运行。一种解决方案是结合问题 194129中提出的解决方法,添加一条规则workflow,即:- if: $CImerge_request_event

image: alpine

workflow:
  rules:
    - if: $CI

stages:
- stage_A
- stage_B

job_A:
  stage: stage_A
  script:
    - echo "Hello from Job A"

job_B:
  stage: stage_B
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - echo "Hello from Job B"
Run Code Online (Sandbox Code Playgroud)

现在我的管道完全在 MR 上运行——这就是我想要的。然而,现在有两条管道正在运行,即分支管道和 MR 管道。

我希望job_A和都job_B在 MR 管道上运行,即使job_A没有规则merge_request_event。但是,我只希望在 MR 打开时运行一个管道 …

gitlab gitlab-ci

5
推荐指数
1
解决办法
1277
查看次数

是否可以使用 eBPF 或 perf 来计算在单个跟踪函数中花费的时间?

目前,我可以告诉trace-cmd(一个 ftrace 前端)使用 ftrace 的函数图基础设施来跟踪指定的工作负载。使用一些跟踪数据处理工具,我可以查看调用函数的频率以及每个函数调用的相应总持续时间。示例输出可能如下所示,其中我跟踪了我的工作负载生成的 ext4 函数调用:

# trace-cmd post-processing example output
# function name, frequency, total duration (us)
ext4_alloc_inode(),1,35.567
ext4_read_inode_bitmap(),1,12.076
ext4_init_io_end(),2,41.216
ext4_journal_check_start(),39,716.3
ext4_da_write_end(),10,102.661
ext4_da_get_block_prep(),9,257.46999999999997
ext4_block_write_begin(),2,88.069
ext4_bio_write_page(),1,33.016
Run Code Online (Sandbox Code Playgroud)

我已经看到了可以由、、等生成的令人难以置信的火焰图,这让我相信我应该能够实现与使用或 的输出类似的输出。但是,有一些障碍:eBPFsystemtapperftrace-cmdperfeBPF

  1. 我的工作负载最多可以运行 15 分钟,如果我使用perf. 作为参考,您可以查看在更短的时间内跟踪 bash 的示例输出
  2. 我不太熟悉,eBPF无法确定是否可以获得与我的trace-cmd后处理示例输出类似的数据/输出。

对于那些比我更熟悉eBPFperf比我更熟悉的人,我想知道:

  • 是否可以使用eBPFperf实现我的目标?
  • 如果是这样,为什么可能?

如果您感觉特别慷慨,将不胜感激能帮助我实现目标的示例代码/命令。

trace ftrace perf bpf ebpf

3
推荐指数
1
解决办法
1330
查看次数

花括号内的 JSX

我有一个条件语句来打印一个字段,如果它不是我想要的空值,然后是一个换行符。此语句存在于<div></div>. 似乎<br />不能在{...}语句中使用(或任何其他 jsx)。

如果满足条件,我想要发生的是有条件地打印我的字符串和换行符。下面我将展示实际发生的事情。

<div>
    {this.props.string ? "$" + this.props.string + <br /> : null}
</div>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,<br />呈现为[object Object].

我也试过

<div>
    {this.props.string ? "$" + this.props.string + "\n" : null}
</div>
Run Code Online (Sandbox Code Playgroud)

但是 "\n" 是按字面打印的。

为什么<br />被渲染为[object Object]?我需要做什么才能达到我想要的结果?

这个问题与此处发现的问题不同,因为我正在寻找内联解决方案,而不必构建具有单个值的数组。

javascript reactjs

3
推荐指数
1
解决办法
1281
查看次数

用 Gitkraken 分裂帅哥

对 Git 存储库中的跟踪文件进行更改后,GitKraken 允许您查看每个文件的默认块。您可以选择“暂存”或“放弃”这些帅哥。

git add --patch提供将大块头分割成更小的块块的选项。我想知道 GitKraken 中是否存在此功能,如果存在,如何使用它。

gitkraken

1
推荐指数
1
解决办法
1030
查看次数

git commit:预填充提交主题但仍提示提交消息

假设我正在分支机构工作,我就跑了git commit.然后我被带到提交消息提示符,我可以在其中输入提交主题和消息.我正在寻找的是一种方法来预先填充提交主题,同时仍然能够手动编写提交消息.

这个问题与不同,因为我希望提交主题,但仍希望提示输入提交消息,即git commit -a在git bash中运行结果如下:

编辑: githooks的不当使用阻止了链接问题的接受答案.因此,问题并不明确,可以将其标记为重复.

git bash中的示例

我目前正在尝试使用分支名称预先填充提交主题,但将来我可能希望该文本是其他内容.因此,优选通用解决方案(不是专门针对分支名称).

git bash commit-message githooks git-commit

0
推荐指数
1
解决办法
167
查看次数